moosetechnology / Famix

An abstract representation of source code. Famix is generic and can describe applications in multiple programming languages.
MIT License
13 stars 23 forks source link

Abnormal generation of external traits #311

Closed enwiro closed 3 years ago

enwiro commented 3 years ago

During the migration from FASTCore to traits, there is a problem with its generation. Indeed, the javaVariableDeclaratorExpressionOwner: method was missing in FASTTExpression. This caused multiple tests to crash because this model could not be called.

image

After the definition of a simplified meta-model of the basic one (FASTJava). We have seen that the generation of 'javaVariableDeclaratorExpressionOwner:' was normally done for this one.

MyModelGenerator>> defineClasses
    super defineClasses.
    javaVariableDeclarator := builder newClassNamed: #VariableDeclarator comment: 'self commentForJavaVariableDeclarator'.

MyModelGenerator>> defineRelations
    super defineRelations.
    ((javaVariableDeclarator property: #expression) comment: 'Expression that s being assigned upon declaration to the var')
        <>- ((tExpression property: #javaVariableDeclaratorExpressionOwner) comment: 'The javaVariableDeclarator owner (if possible)').

MyModelGenerator>> defineTraits
    super defineTraits.
    tExpression := self remoteTrait: #TExpression withPrefix: #FAST. 

By looking for the difference between the two, we found the potential problem. When generating external traits, the generator does not take the right 'realClass'.

image

Therefore the object called was not an 'FM3Trait' but an 'FmxMBBehaviour'. To solve this problem, it is necessary to modify 'generateRemotes' of 'FmxMBTrait' as follows:

image

This problem has, in fact, already been encountered in the past with 'FmxMBClass' and the same modification has been made. ( https://github.com/moosetechnology/Famix/commit/4d2b30d7e35172a6e7f72e32862d488c7d693d23 + https://github.com/moosetechnology/Famix/commit/1ae3c630628be1076c1a5c686aac8e53a83ddfe7 ).

Did I sum up correctly? @badetitou (We found this problem together.)

badetitou commented 3 years ago

Perfectly