moosetechnology / Famix

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

Bug annotation type added to package #767

Open badetitou opened 2 months ago

badetitou commented 2 months ago

When adding a parametric type to a package, the two-ways relation do not work. I would look at a duplication in relation name.

Example to reproduce the bug:

"One way"

famixJavaModel := FamixJavaModel new.
annotationType := famixJavaModel newAnnotationType.
annotationType name: 'AnAnnotation'.

package := famixJavaModel newPackageNamed: 'fr'.
package addType: annotationType.
package types. "a FMSlotMultivalueLink(AnAnnotation (AnnotationType))"
annotationType typeContainer. "nil"

"The other way"

famixJavaModel := FamixJavaModel new.
annotationType := famixJavaModel newAnnotationType.
annotationType name: 'AnAnnotation'.

package := famixJavaModel newPackageNamed: 'fr'.
annotationType typeContainer: package.
package types. "a FMSlotMultivalueLink()"
annotationType typeContainer. "fr (Package)"

In the first example: annotationType typeContainer should return the package "fr" In the second example, the types returns an empty collection

badetitou commented 2 months ago

Looking at the code documentation, I'm using the correct relation image

Gabriel-Darbord commented 2 months ago

The issue is with FamixJavaAnnotationType >> #typeContainer and FamixJavaAnnotationType >> #typeContainer:! It looks like convenience methods for polymorphism between FamixTWithTypes and FamixTWithAnnotationTypes, but it's overwriting the methods from FamixTType.