extending FAMIX meta-model and annotations

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

extending FAMIX meta-model and annotations

Peter Uhnak
Hi,

I'm getting acquainted more with Moose and FAMIX and I am not really sure how to proceed (mostly due to lack of documentation and link rot).

What I want to do is add "multiplicity" attribute to FAMIXAttribute.
Now I see an option:
1) create a subclass of FAMIXAttribute
2) add a method.. something like
FAMIXAttribute>>multiplicity
    <MSEProperty: #multiplicity type: #MyFAMIXMultiplicity>
    ^ multiplicity

now Moose can generate models from smalltalk source code and I would like to infer this information.

For example for types, there is MooseImportingContext>>computeTypeOfAttributes
So I'm assuming I would have to do something similar.

And finally, if I want to help the importer and actually write that information into the source code, I would have to add another pragma there... something like
MyClass>>myAttribute
    <MSEMultiplicity: '2..*' type: MyType>
    ^ myAttribute

and then modify the smalltalk importer to be able to recognize this and produce MyFAMIXAttribute instead of the default one.

Am I on the right track? Should it be done differently?

Any pointers appreciated,
Peter

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: extending FAMIX meta-model and annotations

Peter Uhnak
Another option could be to add magritte descriptions (and thus separating the implementation from the description).

Also it seems that SmalltalkImporter is not trying to compute types for methods... so this would also need either pragmas or descriptions...

On Tue, Sep 8, 2015 at 11:54 PM, Peter Uhnák <[hidden email]> wrote:
Hi,

I'm getting acquainted more with Moose and FAMIX and I am not really sure how to proceed (mostly due to lack of documentation and link rot).

What I want to do is add "multiplicity" attribute to FAMIXAttribute.
Now I see an option:
1) create a subclass of FAMIXAttribute
2) add a method.. something like
FAMIXAttribute>>multiplicity
    <MSEProperty: #multiplicity type: #MyFAMIXMultiplicity>
    ^ multiplicity

now Moose can generate models from smalltalk source code and I would like to infer this information.

For example for types, there is MooseImportingContext>>computeTypeOfAttributes
So I'm assuming I would have to do something similar.

And finally, if I want to help the importer and actually write that information into the source code, I would have to add another pragma there... something like
MyClass>>myAttribute
    <MSEMultiplicity: '2..*' type: MyType>
    ^ myAttribute

and then modify the smalltalk importer to be able to recognize this and produce MyFAMIXAttribute instead of the default one.

Am I on the right track? Should it be done differently?

Any pointers appreciated,
Peter


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: extending FAMIX meta-model and annotations

Nicolas Anquetil
In reply to this post by Peter Uhnak


On 08/09/2015 23:54, Peter Uhnák wrote:
Hi,

I'm getting acquainted more with Moose and FAMIX and I am not really sure how to proceed (mostly due to lack of documentation and link rot).

What I want to do is add "multiplicity" attribute to FAMIXAttribute.
Now I see an option:
1) create a subclass of FAMIXAttribute
You don't need to subclass, you can also use extension
new "instance variable" can be stored in the state of the entity
for example:

FAMIXFunction>>parentModule
    <MSEProperty: #parentModule type: #FAMIXModule>
    <MSEComment: 'Module (typically a file) defining the function.'>
    ^ self privateState        
        attributeAt: #parentModule
        ifAbsentPut: [ nil ]


FAMIXFunction>>parentModule: aModule
    ^ self privateState        
        attributeAt: #parentModule
        put: (
            FMMultivalueLink
                on: self
                update: #functions
                from: self parentModule
                to: aModule
             )

(in this case it's a bit more complex because it is a 1-to-n relation

2) add a method.. something like
FAMIXAttribute>>multiplicity
    <MSEProperty: #multiplicity type: #MyFAMIXMultiplicity>
    ^ multiplicity

now Moose can generate models from smalltalk source code and I would like to infer this information.

For example for types, there is MooseImportingContext>>computeTypeOfAttributes
So I'm assuming I would have to do something similar.
yes, two ways of doing it:
- change the importer to compute the thing on the fly
- post process the model to add the information you want (should be easier)

And finally, if I want to help the importer and actually write that information into the source code, I would have to add another pragma there... something like
MyClass>>myAttribute
    <MSEMultiplicity: '2..*' type: MyType>
    ^ myAttribute

and then modify the smalltalk importer to be able to recognize this and produce MyFAMIXAttribute instead of the default one.
yes, you can change the importer or post process the model as said above
- Take all FamixAttributes
- Find all FamixMethods with the same name and in the same class
- check the pragma in the smalltalk method
- update the FamixAttribute

another way would be to go from the invokers of the pragma and find the FamixAttribute from them

nicolas

Am I on the right track? Should it be done differently?

Any pointers appreciated,
Peter


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev