Skip to content

Commit a656a84

Browse files
authored
Merge pull request #761 from moosetechnology/speed-up-model-generation
Speed up model generation + clean flags
2 parents f89f49c + 7afdec4 commit a656a84

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
lines changed

src/Famix-MetamodelBuilder-Core/FamixMetamodelBuilder.class.st

+8-22
Original file line numberDiff line numberDiff line change
@@ -272,40 +272,26 @@ FamixMetamodelBuilder >> generator: aGenerator [
272272

273273
{ #category : #initialization }
274274
FamixMetamodelBuilder >> getTraitNamed: aSymbol [
275-
276275
"Check if I contain a trait of this name. If yes, return it.
277-
If I do not contain a trait of this name, check if one of my subMM has a trait of this name. If one is found, return it. If more is found raise an error. If non is found, create a new trait of this name and return it."
276+
If no, check if one of my subMM has a trait of this name. If one is found, return it. If more is found raise an error. If non is found, create a new trait of this name and return it."
278277

279278
| remoteTraits |
280-
self flag: #todo. "Maybe we could cache the sub MM entities."
281279
remoteTraits := Dictionary new.
282-
self allSubBuilders do: [ :builder |
280+
self allSubBuilders do: [ :builder |
283281
builder traits
284282
detect: [ :each | each name = aSymbol ]
285283
ifFound: [ :trait | remoteTraits at: builder put: trait ] ].
286-
remoteTraits size = 1 ifTrue: [
284+
remoteTraits size = 1 ifTrue: [
287285
^ remoteTraits values anyOne
288286
isRemote: true;
289287
remoteBuilder: self;
290288
yourself ].
291-
remoteTraits size > 1 ifTrue: [
292-
self error:
293-
('Multiple remote traits named {1} where found in sub metamodels. Found in: {2}.
294-
In order to fix the issue you should use #remoteTrait:withPrefix: in your generator to select yourself the right trait to use. If you want to create an entity of this name in your model and not use the trait of this name from a sub metamodel, declare this trait before referencing it.'
295-
format: {
289+
remoteTraits size > 1 ifTrue: [
290+
self error: ('Multiple remote traits named {1} where found in sub metamodels. Found in: {2}.
291+
In order to fix the issue you should use #remoteTrait:withPrefix: in your generator to select yourself the right trait to use. If you want to create an entity of this name in your model and not use the trait of this name from a sub metamodel, declare this trait before referencing it.'
292+
format: {
296293
aSymbol.
297-
(', ' join:
298-
(remoteTraits keys collect: [ :builder |
299-
builder generator asString ])) }) ].
300-
301-
self flag: #todo. "Cyril: I introduced this warning in the development of Moose 8 to not break every existing generators. We should remove the full detect in the future, for example in the development of Moose 9 (not before!) and revome the warning class."
302-
self traits
303-
detect: [ :each | each name = aSymbol ]
304-
ifFound: [ :trait |
305-
FamixShouldNotUseSymbolsToAccessLocalEntities
306-
signalFor: aSymbol
307-
from: self generator.
308-
^ trait ].
294+
(', ' join: (remoteTraits keys collect: [ :builder | builder generator asString ])) }) ].
309295

310296
^ self traitNamed: aSymbol
311297
]

src/Famix-MetamodelBuilder-Core/FmxMBBehavior.class.st

+10-3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ FmxMBBehavior >> <|-- anObject [
3333
^ anObject
3434
]
3535

36+
{ #category : #accessing }
37+
FmxMBBehavior >> addAllTransitiveTraitsIn: aCollection [
38+
39+
aCollection add: self.
40+
self allLocalTraits do: [ :trait | trait addAllTransitiveTraitsIn: aCollection ].
41+
^ aCollection
42+
]
43+
3644
{ #category : #accessing }
3745
FmxMBBehavior >> addRelation: aRelation with: anotherClass [
3846

@@ -92,9 +100,8 @@ FmxMBBehavior >> allTraitNames [
92100

93101
{ #category : #accessing }
94102
FmxMBBehavior >> allTransitiveTraits [
95-
^ (Set with: self)
96-
addAll: (self allLocalTraits flatCollect: [ :trait | trait allTransitiveTraits ]);
97-
yourself
103+
104+
^ self addAllTransitiveTraitsIn: Set new
98105
]
99106

100107
{ #category : #converting }

0 commit comments

Comments
 (0)