Skip to content

Wrong package: pragma when generating submetamodel remote relation #565

Description

@Gabriel-Darbord

When a metamodel generator includes a submetamodel that has a remote relation with yet another metamodel, then the related method is generated with the package: pragma from the parent generator's packageName as argument.
I believe this is wrong: it should behave as if the method was generated by its original generator, without the package: pragma.

For example:

FooMetamodelGenerator >> defineRelations [
  foo - (self remoteTrait: #TMethod withPrefix: #Famix)
]
FooMetamodelGenerator class >> packageName [
  ^ #'Famix-Foo-Entities'
]

FooMetamodelGenerator generates this method:

method
	<generated>
	<FMProperty: #method type: #FamixTMethod opposite: #foo>
	^ self attributeAt: #method ifAbsent: [ nil ]

Now create a new generator:

FooBarMetamodelGenerator class >> submetamodels [
  ^ { FooMetamodelGenerator }
]
FooBarMetamodelGenerator class >> packageName [
  ^ #'Famix-Foo-Bar-Entities'
]

And generating with it modifies the previous method by adding the package: pragma:

method
	<generated>
	<FMProperty: #method type: #FamixTMethod opposite: #foo>
	<package: #'Famix-Foo-Bar-Entities'>
	^ self attributeAt: #method ifAbsent: [ nil ]

There is a live example in Famix-OpenTelemetry: load the value baseline and try generating with both FamixOpenTelemetryGenerator and FamixOpenTelemetryValueGenerator. Then we can see that the Span>>origin method has this issue.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions