From da02786fd1ed9ef6bacfdd7652e9a27ca5d7d556 Mon Sep 17 00:00:00 2001 From: ClotildeToullec Date: Thu, 9 Feb 2023 15:03:46 +0100 Subject: [PATCH 1/8] Regenerate importers: use only FM3entities, no use to look for Pharo traits --- .../FamixMetamodelBuilder.extension.st | 1 + .../FamixJavaImportingContext.class.st | 202 ++++++++----- .../FamixMetamodelBuilder.class.st | 272 +++++++++++------- .../FmxMBRingEnvironment.class.st | 19 +- .../FamixMetamodelBuilder.extension.st | 1 + .../FmxMBImportingContextTest.class.st | 8 +- .../FamixStImportingContext.class.st | 142 +++++---- .../FamixTest1ImportingContext.class.st | 92 +++--- .../FmxImportingContextTest.class.st | 15 +- src/Moose-Core/FmxImportingContext.class.st | 55 ++-- src/Moose-Core/MooseEntity.class.st | 14 +- src/Moose-Core/MooseModel.class.st | 69 +++-- 12 files changed, 557 insertions(+), 333 deletions(-) diff --git a/src/Famix-Deprecated/FamixMetamodelBuilder.extension.st b/src/Famix-Deprecated/FamixMetamodelBuilder.extension.st index b8ab82985..a04ab3566 100644 --- a/src/Famix-Deprecated/FamixMetamodelBuilder.extension.st +++ b/src/Famix-Deprecated/FamixMetamodelBuilder.extension.st @@ -2,6 +2,7 @@ Extension { #name : #FamixMetamodelBuilder } { #category : #'*Famix-Deprecated' } FamixMetamodelBuilder >> doNotGenerateCurrent [ + self deprecated: 'Only used by deprecated feature.'. self classes do: [ :each | each willGenerate: false ]. self traits do: [ :each | each willGenerate: false ] diff --git a/src/Famix-Java-Entities/FamixJavaImportingContext.class.st b/src/Famix-Java-Entities/FamixJavaImportingContext.class.st index 749ea07b8..9c1271100 100644 --- a/src/Famix-Java-Entities/FamixJavaImportingContext.class.st +++ b/src/Famix-Java-Entities/FamixJavaImportingContext.class.st @@ -4,238 +4,284 @@ Class { #category : #'Famix-Java-Entities' } -{ #category : #testing } +{ #category : #accessing } +FamixJavaImportingContext class >> importedMetamodel [ + + + ^ FamixJavaModel metamodel +] + +{ #category : #importing } FamixJavaImportingContext >> importAccess [ + - ^ self import: FamixJavaAccess + ^ self import: #Access ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importAnnotationInstance [ + - ^ self import: FamixJavaAnnotationInstance + ^ self import: #AnnotationInstance ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importAnnotationInstanceAttribute [ + - ^ self import: FamixJavaAnnotationInstanceAttribute + ^ self import: #AnnotationInstanceAttribute ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importAnnotationType [ + - ^ self import: FamixJavaAnnotationType + ^ self import: #AnnotationType ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importAnnotationTypeAttribute [ + - ^ self import: FamixJavaAnnotationTypeAttribute + ^ self import: #AnnotationTypeAttribute ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importAttribute [ + - ^ self import: FamixJavaAttribute + ^ self import: #Attribute ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importClass [ + - ^ self import: FamixJavaClass + ^ self import: #Class ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importComment [ + - ^ self import: FamixJavaComment + ^ self import: #Comment ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importContainerEntity [ + - ^ self import: FamixJavaContainerEntity + ^ self import: #ContainerEntity ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importEntity [ + - ^ self import: FamixJavaEntity + ^ self import: #Entity ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importEnum [ + - ^ self import: FamixJavaEnum + ^ self import: #Enum ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importEnumValue [ + - ^ self import: FamixJavaEnumValue + ^ self import: #EnumValue ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importException [ + - ^ self import: FamixJavaException + ^ self import: #Exception ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importImplementation [ + - ^ self import: FamixJavaImplementation + ^ self import: #Implementation ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importImplicitVariable [ + - ^ self import: FamixJavaImplicitVariable + ^ self import: #ImplicitVariable ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importImport [ + - ^ self import: FamixJavaImport + ^ self import: #Import ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importIndexedFileAnchor [ + - ^ self import: FamixJavaIndexedFileAnchor + ^ self import: #IndexedFileAnchor ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importInheritance [ + - ^ self import: FamixJavaInheritance + ^ self import: #Inheritance ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importInterface [ + - ^ self import: FamixJavaInterface + ^ self import: #Interface ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importInvocation [ + - ^ self import: FamixJavaInvocation + ^ self import: #Invocation ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importLocalVariable [ + - ^ self import: FamixJavaLocalVariable + ^ self import: #LocalVariable ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importMethod [ + - ^ self import: FamixJavaMethod + ^ self import: #Method ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importNamedEntity [ + - ^ self import: FamixJavaNamedEntity + ^ self import: #NamedEntity ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importPackage [ + - ^ self import: FamixJavaPackage + ^ self import: #Package ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importParameter [ + - ^ self import: FamixJavaParameter + ^ self import: #Parameter ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importParameterType [ + - ^ self import: FamixJavaParameterType + ^ self import: #ParameterType ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importParameterizableClass [ + - ^ self import: FamixJavaParameterizableClass + ^ self import: #ParameterizableClass ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importParameterizableException [ + - ^ self import: FamixJavaParameterizableException + ^ self import: #ParameterizableException ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importParameterizableInterface [ + - ^ self import: FamixJavaParameterizableInterface + ^ self import: #ParameterizableInterface ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importParameterizedType [ + - ^ self import: FamixJavaParameterizedType + ^ self import: #ParameterizedType ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importPrimitiveType [ + - ^ self import: FamixJavaPrimitiveType + ^ self import: #PrimitiveType ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importReference [ + - ^ self import: FamixJavaReference + ^ self import: #Reference ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importSourceAnchor [ + - ^ self import: FamixJavaSourceAnchor + ^ self import: #SourceAnchor ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importSourceLanguage [ + - ^ self import: FamixJavaSourceLanguage + ^ self import: #SourceLanguage ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importSourceTextAnchor [ + - ^ self import: FamixJavaSourceTextAnchor + ^ self import: #SourceTextAnchor ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importSourcedEntity [ + - ^ self import: FamixJavaSourcedEntity + ^ self import: #SourcedEntity ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importType [ + - ^ self import: FamixJavaType + ^ self import: #Type ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importUnknownSourceLanguage [ + - ^ self import: FamixJavaUnknownSourceLanguage + ^ self import: #UnknownSourceLanguage ] -{ #category : #testing } +{ #category : #importing } FamixJavaImportingContext >> importUnknownVariable [ + - ^ self import: FamixJavaUnknownVariable + ^ self import: #UnknownVariable ] { #category : #testing } diff --git a/src/Famix-MetamodelBuilder-Core/FamixMetamodelBuilder.class.st b/src/Famix-MetamodelBuilder-Core/FamixMetamodelBuilder.class.st index bbd5ad4c2..4b0817bd1 100644 --- a/src/Famix-MetamodelBuilder-Core/FamixMetamodelBuilder.class.st +++ b/src/Famix-MetamodelBuilder-Core/FamixMetamodelBuilder.class.st @@ -72,46 +72,56 @@ FamixMetamodelBuilder class >> forGenerator: aGenerator [ { #category : #visitor } FamixMetamodelBuilder >> acceptVisitor: aVisitor [ + ^ aVisitor visitBuilder: self ] { #category : #accessing } FamixMetamodelBuilder >> allSubBuilders [ + ^ self generator ifNil: [ Set new ] ifNotNil: #allSubBuilders ] { #category : #accessing } FamixMetamodelBuilder >> apply [ + self environment apply ] { #category : #accessing } FamixMetamodelBuilder >> baseImportingContextName [ + ^ #FmxImportingContext ] { #category : #accessing } FamixMetamodelBuilder >> behaviorsCount [ + ^ self traits size + self classes size ] { #category : #initialization } FamixMetamodelBuilder >> classNamed: aClassName [ - "empty block returns nil anyway" - ^ self classes detect: [ :each | each name = aClassName] ifNone: [ nil ] + + ^ self classes + detect: [ :each | each name = aClassName ] + ifNone: [ nil ] ] { #category : #accessing } FamixMetamodelBuilder >> classes [ + ^ classes ] { #category : #accessing } FamixMetamodelBuilder >> configuration [ + ^ configuration ] @@ -124,74 +134,101 @@ FamixMetamodelBuilder >> configuration: anObject [ { #category : #initialization } FamixMetamodelBuilder >> ensureClassNamed: aString [ - ^ self classes detect: [ :each | each name = aString ] ifNone: [ self newClassNamed: aString ] + + ^ self classes + detect: [ :each | each name = aString ] + ifNone: [ self newClassNamed: aString ] ] { #category : #generating } FamixMetamodelBuilder >> ensureEntityClassIsTheCommonSuperclass [ + "All classes should have a common superclass called Entity. Here we ensure it is created and used." - self classes iterator - | #isRoot selectIt - | #isMetamodelClassGroup rejectIt - | #isModelClass rejectIt - | [ :class | class name = #Entity ] rejectIt - | [ :class | class --|> (self ensureClassNamed: #Entity) ] doIt - > NullAddableObject + self classes iterator | #isRoot selectIt + | #isMetamodelClassGroup rejectIt | #isModelClass rejectIt + | [ :class | class name = #Entity ] rejectIt + | [ :class | class --|> (self ensureClassNamed: #Entity) ] doIt + > NullAddableObject ] { #category : #initialization } FamixMetamodelBuilder >> ensureLocalTraitNamed: aString [ - - ^ self traits detect: [ :each | each name = aString and: [ each prefix = self configuration prefix ] ] ifNone: [ self unsafeNewTraitNamed: aString ] + + + ^ self traits + detect: [ :each | + each name = aString and: [ + each prefix = self configuration prefix ] ] + ifNone: [ self unsafeNewTraitNamed: aString ] ] { #category : #accessing } FamixMetamodelBuilder >> environment [ + ^ environment ] { #category : #accessing } FamixMetamodelBuilder >> environment: anObject [ + environment := anObject ] { #category : #generating } FamixMetamodelBuilder >> generate [ + self prepareGeneration. self apply ] { #category : #generating } FamixMetamodelBuilder >> generateImportIn: contextClass [ - self classes - do: [ :each | - "No need to generate methods for model class." - each isModelClass - ifFalse: [ self environment - compile: - ('import{1} + + self classes do: [ :each | "No need to generate methods for model class." + each isModelClass ifFalse: [ + self environment + compile: ('import{1} + - ^ self import: {2}' format: {each name . each fullName}) - in: contextClass - classified: 'testing' ] ] + ^ self import: #{2}' format: { + each name. + each name }) + in: contextClass + classified: 'importing' ] ] ] { #category : #generating } FamixMetamodelBuilder >> generateImportingContext [ | contextClass | - self configuration wantsToGenerateImportingContext ifFalse: [ ^ self ]. - contextClass := self environment createImportingcontextClassNamed: self importingContextName in: self configuration packageName. - + contextClass := self environment + createImportingcontextClassNamed: + self importingContextName + in: self configuration packageName. + + self generateImportingContextMetamodelIn: contextClass. self generateShouldImportIn: contextClass. self generateImportIn: contextClass ] +{ #category : #generating } +FamixMetamodelBuilder >> generateImportingContextMetamodelIn: contextClass [ + + self environment + compile: ('importedMetamodel + + + ^ {1}Model metamodel' format: { self configuration prefix }) + in: contextClass classSide + classified: 'accessing' +] + { #category : #generating } FamixMetamodelBuilder >> generateRemotes [ + self traits do: [ :each | each generateRemotes ]. self classes do: [ :each | each generateRemotes ]. @@ -200,21 +237,22 @@ FamixMetamodelBuilder >> generateRemotes [ { #category : #generating } FamixMetamodelBuilder >> generateShouldImportIn: contextClass [ - self classes - do: [ :each | - "No need to generate methods for model class." - each isModelClass - ifFalse: [ self environment - compile: - ('shouldImport{1} + + self classes do: [ :each | "No need to generate methods for model class." + each isModelClass ifFalse: [ + self environment + compile: ('shouldImport{1} - ^ self shouldImport: {2}' format: {each name . each fullName}) - in: contextClass - classified: 'testing' ] ] + ^ self shouldImport: {2}' format: { + each name. + each fullName }) + in: contextClass + classified: 'testing' ] ] ] { #category : #accessing } FamixMetamodelBuilder >> generator [ + ^ generator ] @@ -223,40 +261,44 @@ FamixMetamodelBuilder >> generator [ FamixMetamodelBuilder >> generator: aGenerator [ - generator := aGenerator. - + generator := aGenerator ] { #category : #initialization } FamixMetamodelBuilder >> getTraitNamed: aSymbol [ + "Check if I contain a trait of this name. If yes, return it. 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." | remoteTraits | - self flag: #todo. "Maybe we could cache the sub MM entities." + self flag: #todo. "Maybe we could cache the sub MM entities." remoteTraits := Dictionary new. - self allSubBuilders - do: [ :builder | - builder traits - detect: [ :each | each name = aSymbol ] - ifFound: [ :trait | remoteTraits at: builder put: trait ] ]. - remoteTraits size = 1 - ifTrue: [ ^ remoteTraits values anyOne - isRemote: true; - remoteBuilder: self; - yourself ]. - remoteTraits size > 1 - ifTrue: [ self - error: - ('Multiple remote traits named {1} where found in sub metamodels. Found in: {2}. -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.' - format: {aSymbol . (', ' join: (remoteTraits keys collect: [ :builder | builder generator asString ]))}) ]. - - 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." + self allSubBuilders do: [ :builder | + builder traits + detect: [ :each | each name = aSymbol ] + ifFound: [ :trait | remoteTraits at: builder put: trait ] ]. + remoteTraits size = 1 ifTrue: [ + ^ remoteTraits values anyOne + isRemote: true; + remoteBuilder: self; + yourself ]. + remoteTraits size > 1 ifTrue: [ + self error: + ('Multiple remote traits named {1} where found in sub metamodels. Found in: {2}. +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.' + format: { + aSymbol. + (', ' join: + (remoteTraits keys collect: [ :builder | + builder generator asString ])) }) ]. + + 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." self traits detect: [ :each | each name = aSymbol ] ifFound: [ :trait | - FamixShouldNotUseSymbolsToAccessLocalEntities signalFor: aSymbol from: self generator. + FamixShouldNotUseSymbolsToAccessLocalEntities + signalFor: aSymbol + from: self generator. ^ trait ]. ^ self traitNamed: aSymbol @@ -264,25 +306,28 @@ In order to fix the issue you should use #remoteTrait:withPrefix: in your genera { #category : #generating } FamixMetamodelBuilder >> groupOf: aClass [ + | group | group := (self newClassGroupNamed: aClass name , 'Group') - innerClass: aClass; - yourself. + innerClass: aClass; + yourself. ^ group ] { #category : #accessing } FamixMetamodelBuilder >> importingContextName [ + ^ (self configuration prefix , 'ImportingContext') asSymbol ] { #category : #initialization } FamixMetamodelBuilder >> initialize [ + super initialize. environment := FmxMBRealRingEnvironment for: self. configuration := FmxMBConfiguration new. - importedFromFile := true. "should be set in configuration ???" + importedFromFile := true. "should be set in configuration ???" classes := OrderedCollection new. traits := OrderedCollection new. @@ -292,18 +337,19 @@ FamixMetamodelBuilder >> initialize [ { #category : #accessing } FamixMetamodelBuilder >> isImportedFromFile [ - ^ importedFromFile + ^ importedFromFile ] { #category : #initialization } FamixMetamodelBuilder >> model [ + | aClass | "can only have one model by generator, so return the model class if already created" self classes detect: #isModelClass ifFound: [ :found | ^ found ]. - self configuration prefix - ifEmpty: [ ^ nil "In case of empty prefix, it would generate a classe name Model which is not possible in Pharo. Thus we prevent this case." ]. + self configuration prefix ifEmpty: [ + ^ nil "In case of empty prefix, it would generate a classe name Model which is not possible in Pharo. Thus we prevent this case." ]. aClass := FmxMBModel new. aClass builder: self. @@ -317,56 +363,56 @@ FamixMetamodelBuilder >> model [ FamixMetamodelBuilder >> newClass [ | aClass | - aClass := FmxMBClass new. aClass builder: self. aClass prefix: self configuration prefix. aClass packageName: self configuration packageName. self classes add: aClass. ^ aClass - ] { #category : #initialization } FamixMetamodelBuilder >> newClassGroup [ | aClass | - aClass := FmxMBClassGroup new. aClass builder: self. aClass prefix: self configuration prefix. aClass packageName: self configuration packageName. self classes add: aClass. ^ aClass - ] { #category : #initialization } FamixMetamodelBuilder >> newClassGroupNamed: aClassName [ - (self classes select: [ :each | each name = aClassName ]) ifNotEmpty: [ FmxMBEntityAlreadyExists signal ]. + + (self classes select: [ :each | each name = aClassName ]) + ifNotEmpty: [ FmxMBEntityAlreadyExists signal ]. ^ self newClassGroup name: aClassName ] { #category : #initialization } FamixMetamodelBuilder >> newClassNamed: aClassName [ - (self classes select: [ :each | each name = aClassName ]) ifNotEmpty: [ FmxMBEntityAlreadyExists signal ]. + + (self classes select: [ :each | each name = aClassName ]) + ifNotEmpty: [ FmxMBEntityAlreadyExists signal ]. ^ self newClass name: aClassName ] { #category : #initialization } FamixMetamodelBuilder >> newClassNamed: aClassName comment: aString [ + ^ (self newClassNamed: aClassName) - comment: aString; - yourself + comment: aString; + yourself ] { #category : #initialization } FamixMetamodelBuilder >> newRelation [ | aRelation | - aRelation := FmxMBRelation new. aRelation builder: self. self relations add: aRelation. @@ -374,40 +420,44 @@ FamixMetamodelBuilder >> newRelation [ ] { #category : #initialization } -FamixMetamodelBuilder >> newTrait [ +FamixMetamodelBuilder >> newTrait [ | aTrait | - aTrait := FmxMBTrait new. aTrait builder: self. aTrait prefix: self configuration prefix. aTrait packageName: self configuration packageName. self traits add: aTrait. ^ aTrait - ] { #category : #initialization } FamixMetamodelBuilder >> newTraitNamed: aTraitName [ - (self traits select: [ :each | each fullName = (self configuration prefix , aTraitName) ]) ifNotEmpty: [ FmxMBEntityAlreadyExists signal ]. + + (self traits select: [ :each | + each fullName = (self configuration prefix , aTraitName) ]) + ifNotEmpty: [ FmxMBEntityAlreadyExists signal ]. ^ self unsafeNewTraitNamed: aTraitName ] { #category : #initialization } FamixMetamodelBuilder >> newTraitNamed: aClassName comment: aString [ + ^ (self newTraitNamed: aClassName) - comment: aString; - yourself + comment: aString; + yourself ] { #category : #accessing } FamixMetamodelBuilder >> notImportedFromFile [ + importedFromFile := false ] { #category : #accessing } FamixMetamodelBuilder >> parentBuilder [ + ^ parentBuilder ] @@ -429,13 +479,18 @@ FamixMetamodelBuilder >> parentBuilderPackageName [ { #category : #generating } FamixMetamodelBuilder >> prepareGeneration [ + self registerPackages. self ensureEntityClassIsTheCommonSuperclass. - "ensure the model entity exists before geenrating" - (self behaviorsCount > 0 or: [ self relations size > 0 or: [ self subBuilders size > 0 ] ]) ifTrue: [ self model ]. - self traitsWithSubBuildersTraits do: [ :each | self testingSelectorsMapping at: each put: each testingSelectors ]. - self classes do: [ :each | self testingSelectorsMapping at: each put: each testingSelectors ]. + "ensure the model entity exists before generating" + (self behaviorsCount > 0 or: [ + self relations size > 0 or: [ self subBuilders size > 0 ] ]) + ifTrue: [ self model ]. + self traitsWithSubBuildersTraits do: [ :each | + self testingSelectorsMapping at: each put: each testingSelectors ]. + self classes do: [ :each | + self testingSelectorsMapping at: each put: each testingSelectors ]. self traits do: [ :each | each generate ]. self sortedClasses do: [ :each | each generate ]. self behaviorsCount > 0 ifTrue: [ self generateImportingContext ] @@ -443,63 +498,76 @@ FamixMetamodelBuilder >> prepareGeneration [ { #category : #printing } FamixMetamodelBuilder >> printOn: aStream [ + super printOn: aStream. - self generator - ifNotNil: [ :g | - aStream - nextPut: $(; - print: g class; - nextPut: $) ] + self generator ifNotNil: [ :g | + aStream + nextPut: $(; + print: g class; + nextPut: $) ] ] { #category : #generating } FamixMetamodelBuilder >> regenerationIsNeeded [ + self prepareGeneration. ^ self environment regenerationIsNeeded ] { #category : #generating } FamixMetamodelBuilder >> registerPackages [ + self environment registerPackage: self configuration packageName ] { #category : #accessing } FamixMetamodelBuilder >> relations [ + ^ relations ] { #category : #accessing } FamixMetamodelBuilder >> relations: anObject [ + relations := anObject ] { #category : #accessing } FamixMetamodelBuilder >> reservedKeywords [ - ^ { #'class' } + + ^ { #class } ] { #category : #accessing } FamixMetamodelBuilder >> safeAnnotationPackageName [ + ^ self configuration packageNameForAnnotations asSymbol printString ] { #category : #accessing } FamixMetamodelBuilder >> sortedClasses [ - - ^ self classes sorted: [ :class | class allClassGeneralizations size ] ascending + + + ^ self classes sorted: + [ :class | class allClassGeneralizations size ] ascending ] { #category : #accessing } FamixMetamodelBuilder >> sortedTraits [ - - ^ self traits sorted: [ :a :b | a allTraitGeneralizations size <= b allTraitGeneralizations size and: [ a name <= b name ] ] + + + ^ self traits sorted: [ :a :b | + a allTraitGeneralizations size <= b allTraitGeneralizations size + and: [ a name <= b name ] ] ] { #category : #accessing } FamixMetamodelBuilder >> subBuilders [ - ^ self generator ifNil: [ #() ] ifNotNil: #subBuilders + + ^ self generator ifNil: [ #( ) ] ifNotNil: #subBuilders ] { #category : #'tests support' } @@ -510,26 +578,31 @@ FamixMetamodelBuilder >> testingEnvironment [ { #category : #accessing } FamixMetamodelBuilder >> testingSelectorsMapping [ + ^ testingSelectorsMapping ] { #category : #initialization } FamixMetamodelBuilder >> traitNamed: aString [ - ^ self traits - detect: [ :each | each name = aString ] - ifNone: [ FamixMetamodelGeneratorUnknownTrait signal: 'Trait ' , aString , ' not found in the metamodel. Please add it or refer to a submetamodel.' ] + + ^ self traits detect: [ :each | each name = aString ] ifNone: [ + FamixMetamodelGeneratorUnknownTrait signal: 'Trait ' , aString + , + ' not found in the metamodel. Please add it or refer to a submetamodel.' ] ] { #category : #accessing } FamixMetamodelBuilder >> traits [ + ^ traits ] { #category : #accessing } FamixMetamodelBuilder >> traitsWithSubBuildersTraits [ + ^ (self allSubBuilders flatCollect: #traits) - addAll: self traits; - yourself + addAll: self traits; + yourself ] { #category : #initialization } @@ -541,5 +614,6 @@ FamixMetamodelBuilder >> unsafeNewTraitNamed: aTraitName [ { #category : #accessing } FamixMetamodelBuilder >> withImportingContext [ + self configuration wantsToGenerateImportingContext: true ] diff --git a/src/Famix-MetamodelBuilder-Core/FmxMBRingEnvironment.class.st b/src/Famix-MetamodelBuilder-Core/FmxMBRingEnvironment.class.st index 68c9f10f8..7d6f4f0a7 100644 --- a/src/Famix-MetamodelBuilder-Core/FmxMBRingEnvironment.class.st +++ b/src/Famix-MetamodelBuilder-Core/FmxMBRingEnvironment.class.st @@ -107,17 +107,18 @@ FmxMBRingEnvironment >> createClassNamed: aClassName superclass: aSuperclass tra FmxMBRingEnvironment >> createImportingcontextClassNamed: aClassName in: packageName [ | resultantClass | - - (self hasBehaviorNamed: aClassName asSymbol ) - ifTrue: [ ^ self ringEnvironment ensureClassNamed: aClassName asSymbol ]. - - resultantClass := self ringEnvironment ensureClassNamed: aClassName asSymbol. - resultantClass superclass: (self ringEnvironment ensureClassNamed: self builder baseImportingContextName). + (self hasBehaviorNamed: aClassName asSymbol) ifTrue: [ + ^ self ringEnvironment ensureClassNamed: aClassName asSymbol ]. + + resultantClass := self ringEnvironment ensureClassNamed: + aClassName asSymbol. + resultantClass superclass: (self ringEnvironment ensureClassNamed: + self builder baseImportingContextName). resultantClass layout makeResolved. - resultantClass package: (self ringEnvironment ensurePackageNamed: packageName). - - ^ resultantClass + resultantClass package: + (self ringEnvironment ensurePackageNamed: packageName). + ^ resultantClass ] { #category : #initialization } diff --git a/src/Famix-MetamodelBuilder-Tests/FamixMetamodelBuilder.extension.st b/src/Famix-MetamodelBuilder-Tests/FamixMetamodelBuilder.extension.st index 01d7fd480..bc10d1e56 100644 --- a/src/Famix-MetamodelBuilder-Tests/FamixMetamodelBuilder.extension.st +++ b/src/Famix-MetamodelBuilder-Tests/FamixMetamodelBuilder.extension.st @@ -2,6 +2,7 @@ Extension { #name : #FamixMetamodelBuilder } { #category : #'*Famix-MetamodelBuilder-Tests' } FamixMetamodelBuilder >> beForTesting [ + self environment: (FmxMBRingEnvironment for: self). self configuration diff --git a/src/Famix-MetamodelBuilder-Tests/FmxMBImportingContextTest.class.st b/src/Famix-MetamodelBuilder-Tests/FmxMBImportingContextTest.class.st index ae441e5ad..a303af4d8 100644 --- a/src/Famix-MetamodelBuilder-Tests/FmxMBImportingContextTest.class.st +++ b/src/Famix-MetamodelBuilder-Tests/FmxMBImportingContextTest.class.st @@ -38,11 +38,11 @@ FmxMBImportingContextTest >> setUp [ FmxMBImportingContextTest >> testDefineImport [ | localMethod | - localMethod := generatedContext methodNamed: #importMethod. - self assert: (localMethod sourceCode includesSubstring: ''). - self assert: (localMethod sourceCode includesSubstring: '^ self import: TstMethod'). - + self assert: + (localMethod sourceCode includesSubstring: ''). + self assert: + (localMethod sourceCode includesSubstring: '^ self import: #Method') ] { #category : #tests } diff --git a/src/Famix-PharoSmalltalk-Entities/FamixStImportingContext.class.st b/src/Famix-PharoSmalltalk-Entities/FamixStImportingContext.class.st index 7ef53cbd4..c65a92b83 100644 --- a/src/Famix-PharoSmalltalk-Entities/FamixStImportingContext.class.st +++ b/src/Famix-PharoSmalltalk-Entities/FamixStImportingContext.class.st @@ -4,166 +4,200 @@ Class { #category : #'Famix-PharoSmalltalk-Entities' } -{ #category : #testing } +{ #category : #accessing } +FamixStImportingContext class >> importedMetamodel [ + + + ^ FamixStModel metamodel +] + +{ #category : #importing } FamixStImportingContext >> importAccess [ + - ^ self import: FamixStAccess + ^ self import: #Access ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importAnnotationInstance [ + - ^ self import: FamixStAnnotationInstance + ^ self import: #AnnotationInstance ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importAnnotationInstanceAttribute [ + - ^ self import: FamixStAnnotationInstanceAttribute + ^ self import: #AnnotationInstanceAttribute ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importAnnotationType [ + - ^ self import: FamixStAnnotationType + ^ self import: #AnnotationType ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importAnnotationTypeAttribute [ + - ^ self import: FamixStAnnotationTypeAttribute + ^ self import: #AnnotationTypeAttribute ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importAttribute [ + - ^ self import: FamixStAttribute + ^ self import: #Attribute ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importClass [ + - ^ self import: FamixStClass + ^ self import: #Class ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importComment [ + - ^ self import: FamixStComment + ^ self import: #Comment ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importEntity [ + - ^ self import: FamixStEntity + ^ self import: #Entity ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importGlobalVariable [ + - ^ self import: FamixStGlobalVariable + ^ self import: #GlobalVariable ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importImplicitVariable [ + - ^ self import: FamixStImplicitVariable + ^ self import: #ImplicitVariable ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importInheritance [ + - ^ self import: FamixStInheritance + ^ self import: #Inheritance ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importInvocation [ + - ^ self import: FamixStInvocation + ^ self import: #Invocation ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importLocalVariable [ + - ^ self import: FamixStLocalVariable + ^ self import: #LocalVariable ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importMethod [ + - ^ self import: FamixStMethod + ^ self import: #Method ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importNamedEntity [ + - ^ self import: FamixStNamedEntity + ^ self import: #NamedEntity ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importNamespace [ + - ^ self import: FamixStNamespace + ^ self import: #Namespace ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importPackage [ + - ^ self import: FamixStPackage + ^ self import: #Package ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importParameter [ + - ^ self import: FamixStParameter + ^ self import: #Parameter ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importPharoEntitySourceAnchor [ + - ^ self import: FamixStPharoEntitySourceAnchor + ^ self import: #PharoEntitySourceAnchor ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importReference [ + - ^ self import: FamixStReference + ^ self import: #Reference ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importSourceAnchor [ + - ^ self import: FamixStSourceAnchor + ^ self import: #SourceAnchor ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importSourceLanguage [ + - ^ self import: FamixStSourceLanguage + ^ self import: #SourceLanguage ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importSourceTextAnchor [ + - ^ self import: FamixStSourceTextAnchor + ^ self import: #SourceTextAnchor ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importSourcedEntity [ + - ^ self import: FamixStSourcedEntity + ^ self import: #SourcedEntity ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importUnknownSourceLanguage [ + - ^ self import: FamixStUnknownSourceLanguage + ^ self import: #UnknownSourceLanguage ] -{ #category : #testing } +{ #category : #importing } FamixStImportingContext >> importUnknownVariable [ + - ^ self import: FamixStUnknownVariable + ^ self import: #UnknownVariable ] { #category : #testing } diff --git a/src/Famix-Test1-Entities/FamixTest1ImportingContext.class.st b/src/Famix-Test1-Entities/FamixTest1ImportingContext.class.st index 0c5672880..eaa537e92 100644 --- a/src/Famix-Test1-Entities/FamixTest1ImportingContext.class.st +++ b/src/Famix-Test1-Entities/FamixTest1ImportingContext.class.st @@ -4,106 +4,130 @@ Class { #category : #'Famix-Test1-Entities' } -{ #category : #testing } +{ #category : #accessing } +FamixTest1ImportingContext class >> importedMetamodel [ + + + ^ FamixTest1Model metamodel +] + +{ #category : #importing } FamixTest1ImportingContext >> importAssociation [ + - ^ self import: FamixTest1Association + ^ self import: #Association ] -{ #category : #testing } +{ #category : #importing } FamixTest1ImportingContext >> importAttribute [ + - ^ self import: FamixTest1Attribute + ^ self import: #Attribute ] -{ #category : #testing } +{ #category : #importing } FamixTest1ImportingContext >> importClass [ + - ^ self import: FamixTest1Class + ^ self import: #Class ] -{ #category : #testing } +{ #category : #importing } FamixTest1ImportingContext >> importComment [ + - ^ self import: FamixTest1Comment + ^ self import: #Comment ] -{ #category : #testing } +{ #category : #importing } FamixTest1ImportingContext >> importEntity [ + - ^ self import: FamixTest1Entity + ^ self import: #Entity ] -{ #category : #testing } +{ #category : #importing } FamixTest1ImportingContext >> importFile [ + - ^ self import: FamixTest1File + ^ self import: #File ] -{ #category : #testing } +{ #category : #importing } FamixTest1ImportingContext >> importFileAnchor [ + - ^ self import: FamixTest1FileAnchor + ^ self import: #FileAnchor ] -{ #category : #testing } +{ #category : #importing } FamixTest1ImportingContext >> importFolder [ + - ^ self import: FamixTest1Folder + ^ self import: #Folder ] -{ #category : #testing } +{ #category : #importing } FamixTest1ImportingContext >> importIndexedFileAnchor [ + - ^ self import: FamixTest1IndexedFileAnchor + ^ self import: #IndexedFileAnchor ] -{ #category : #testing } +{ #category : #importing } FamixTest1ImportingContext >> importMethod [ + - ^ self import: FamixTest1Method + ^ self import: #Method ] -{ #category : #testing } +{ #category : #importing } FamixTest1ImportingContext >> importMultipleFileAnchor [ + - ^ self import: FamixTest1MultipleFileAnchor + ^ self import: #MultipleFileAnchor ] -{ #category : #testing } +{ #category : #importing } FamixTest1ImportingContext >> importNamedEntity [ + - ^ self import: FamixTest1NamedEntity + ^ self import: #NamedEntity ] -{ #category : #testing } +{ #category : #importing } FamixTest1ImportingContext >> importSourceAnchor [ + - ^ self import: FamixTest1SourceAnchor + ^ self import: #SourceAnchor ] -{ #category : #testing } +{ #category : #importing } FamixTest1ImportingContext >> importSourceLanguage [ + - ^ self import: FamixTest1SourceLanguage + ^ self import: #SourceLanguage ] -{ #category : #testing } +{ #category : #importing } FamixTest1ImportingContext >> importSourceTextAnchor [ + - ^ self import: FamixTest1SourceTextAnchor + ^ self import: #SourceTextAnchor ] -{ #category : #testing } +{ #category : #importing } FamixTest1ImportingContext >> importSourcedEntity [ + - ^ self import: FamixTest1SourcedEntity + ^ self import: #SourcedEntity ] -{ #category : #testing } +{ #category : #importing } FamixTest1ImportingContext >> importUnknownSourceLanguage [ + - ^ self import: FamixTest1UnknownSourceLanguage + ^ self import: #UnknownSourceLanguage ] { #category : #testing } diff --git a/src/Famix-Test1-Tests/FmxImportingContextTest.class.st b/src/Famix-Test1-Tests/FmxImportingContextTest.class.st index adbb4e4f6..a4d80458d 100644 --- a/src/Famix-Test1-Tests/FmxImportingContextTest.class.st +++ b/src/Famix-Test1-Tests/FmxImportingContextTest.class.st @@ -49,14 +49,13 @@ source2b'')) { #category : #tests } FmxImportingContextTest >> testImportingClasses [ - self modelMSE - readStreamDo: [ :s | - model := FamixTest1Model - importFromMSEStream: s - filteredBy: - (FamixTest1ImportingContext new - importClass; - yourself) ]. + + self modelMSE readStreamDo: [ :s | + model := FamixTest1Model + importFromMSEStream: s + filteredBy: (FamixTest1ImportingContext new + importClass; + yourself) ]. self assert: model entities size equals: 2. self assert: (model allUsing: FamixTClass) size equals: 2. self assertEmpty: (model allUsing: FamixTMethod). diff --git a/src/Moose-Core/FmxImportingContext.class.st b/src/Moose-Core/FmxImportingContext.class.st index 7e3baa473..85ac971cc 100644 --- a/src/Moose-Core/FmxImportingContext.class.st +++ b/src/Moose-Core/FmxImportingContext.class.st @@ -10,33 +10,48 @@ Class { #category : #'Moose-Core' } -{ #category : #accessing } -FmxImportingContext >> import: aClass [ - - self import: aClass traversed: Set new - +{ #category : #'importing-filters' } +FmxImportingContext >> containersOf: aFM3Class [ + + | allMetamodelClasses | + allMetamodelClasses := self class importedMetamodel classes. + + ^ aFM3Class allContainerProperties flatCollectAsSet: [ :prop | + prop type isFM3Trait + ifTrue: [ + allMetamodelClasses select: [ :fm3Class | + fm3Class traits includes: prop type ] ] + ifFalse: [ { prop type } ] ] ] -{ #category : #accessing } -FmxImportingContext >> import: aClass traversed: traversedClasses [ - - (traversedClasses includes: aClass) - ifTrue: [ ^ self ]. - - self imports add: aClass. - traversedClasses add: aClass. - - aClass requirements do: [ :each | - self import: each traversed: traversedClasses ]. - +{ #category : #'importing-filters' } +FmxImportingContext >> import: aClassName [ + + self + import: (self class importedMetamodel elements detect: [ :e | + e name = aClassName ]) + traversed: Set new +] + +{ #category : #'importing-filters' } +FmxImportingContext >> import: aFM3Class traversed: traversedClasses [ + + (traversedClasses includes: aFM3Class) ifTrue: [ ^ self ]. + + self imports add: aFM3Class. + traversedClasses add: aFM3Class. + + (self containersOf: aFM3Class) do: [ :fm3Behavior | + self import: fm3Behavior traversed: traversedClasses ] ] { #category : #'importing-filters' } FmxImportingContext >> importMaximum [ + (self class methods - select: [ :m | m selector beginsWith: #import ] - thenCollect: #selector) \ #(importMaximum) - do: [ :aSelector | self perform: aSelector ] + select: [ :m | m selector beginsWith: #import ] + thenCollect: #selector) \ #( importMaximum ) do: [ :aSelector | + self perform: aSelector ] ] { #category : #accessing } diff --git a/src/Moose-Core/MooseEntity.class.st b/src/Moose-Core/MooseEntity.class.st index 4da2187fb..3d8f32661 100644 --- a/src/Moose-Core/MooseEntity.class.st +++ b/src/Moose-Core/MooseEntity.class.st @@ -70,15 +70,19 @@ MooseEntity class >> model: aMooseModel [ { #category : #accessing } MooseEntity class >> requirements [ + | metamodelClasses usedBehaviors | metamodelClasses := self metamodel concreteImplementingClasses. - usedBehaviors := (self allDeclaredPropertiesIn: self metamodel) select: #isContainer thenCollect: [ :p | p opposite implementingClass ]. + usedBehaviors := (self allDeclaredPropertiesIn: self metamodel) + select: #isContainer + thenCollect: [ :p | p opposite implementingClass ]. - ^ (usedBehaviors flatCollect: [ :aBehavior | - aBehavior isTrait - ifTrue: [ metamodelClasses select: [ :each | each isComposedBy: aBehavior ] ] - ifFalse: [ {aBehavior} ] ]) asSet + ^ (usedBehaviors flatCollect: [ :aBehavior | + aBehavior isTrait + ifTrue: [ + metamodelClasses select: [ :each | each isComposedBy: aBehavior ] ] + ifFalse: [ { aBehavior } ] ]) asSet ] { #category : #dependencies } diff --git a/src/Moose-Core/MooseModel.class.st b/src/Moose-Core/MooseModel.class.st index ab6cf2bd0..4bad1f64f 100644 --- a/src/Moose-Core/MooseModel.class.st +++ b/src/Moose-Core/MooseModel.class.st @@ -157,11 +157,18 @@ MooseModel class >> importFrom: aStream withMetamodel: aMetamodel customizingImp { #category : #'import-export' } MooseModel class >> importFrom: aStream withMetamodel: aMetamodel filteredBy: anImportingContext [ + "In the way to import a model we filter the entites we want to import via a FmxImportContext." | famixElementNames | - famixElementNames := anImportingContext imports collect: [ :each | each mooseDescription fullName ]. - ^ self importFrom: aStream withMetamodel: aMetamodel customizingImporterWith: [ :importer | FMImporterFilter on: importer filtering: famixElementNames ] + famixElementNames := anImportingContext imports collect: [ :each | + each fullName ]. + + ^ self + importFrom: aStream + withMetamodel: aMetamodel + customizingImporterWith: [ :importer | + FMImporterFilter on: importer filtering: famixElementNames ] ] { #category : #'import-export' } @@ -220,9 +227,10 @@ MooseModel class >> importFromMSEStream: aStream [ { #category : #'import-export' } MooseModel class >> importFromMSEStream: aStream filteredBy: anImportingContext [ + ^ self new - importFromMSEStream: aStream filteredBy: anImportingContext; - yourself + importFromMSEStream: aStream filteredBy: anImportingContext; + yourself ] { #category : #'import-export' } @@ -343,6 +351,7 @@ MooseModel >> addAll: entities [ { #category : #'entity collection' } MooseModel >> addNoAnnounce: anElement [ + self entityStorage add: anElement. self flush. anElement privateSetMooseModel: self. @@ -508,6 +517,7 @@ MooseModel >> flushPrivateState [ { #category : #actions } MooseModel >> importFrom: aFMModel named: aString [ + self silentlyAddAll: aFMModel elements. self entityStorage forRuntime. self name: aString @@ -531,6 +541,7 @@ MooseModel >> importFromJSON [ { #category : #actions } MooseModel >> importFromJSONStream: aStream [ + "Benchmarks Time millisecondsToRun: [ MooseModel new importFromJSONStream: (StandardFileStream readOnlyFileNamed: 'network3.json') ]. Time millisecondsToRun: [ MooseModel new importFromJSONStream: (StandardFileStream readOnlyFileNamed: 'moose.json') ]. 178163 simon.denier 9/11/2009 12:29 @@ -539,14 +550,21 @@ MooseModel >> importFromJSONStream: aStream [ 17560 -> simon_denier 9/21/2009 22:34 - removing metrics from MSE " - ^ self importFrom: (self class importFromJSON: aStream withMetamodel: self metamodel) named: (aStream localName removeSuffix: '.json') + ^ self + importFrom: + (self class importFromJSON: aStream withMetamodel: self metamodel) + named: (aStream localName removeSuffix: '.json') ] { #category : #actions } MooseModel >> importFromJSONStream: aStream filteredBy: anImportingContext [ + ^ self - importFrom: (self class importFrom: aStream withMetamodel: self metamodel filteredBy: anImportingContext) - named: (aStream localName removeSuffix: '.json') + importFrom: (self class + importFrom: aStream + withMetamodel: self metamodel + filteredBy: anImportingContext) + named: (aStream localName removeSuffix: '.json') ] { #category : #'import-export' } @@ -567,6 +585,7 @@ MooseModel >> importFromMSE [ { #category : #actions } MooseModel >> importFromMSEStream: aStream [ + "Benchmarks Time millisecondsToRun: [ MooseModel new importFromMSEStream: (StandardFileStream readOnlyFileNamed: 'network3.mse') ]. Time millisecondsToRun: [ MooseModel new importFromMSEStream: (StandardFileStream readOnlyFileNamed: 'moose.mse') ]. 178163 simon.denier 9/11/2009 12:29 @@ -575,14 +594,21 @@ MooseModel >> importFromMSEStream: aStream [ 17560 -> simon_denier 9/21/2009 22:34 - removing metrics from MSE " - ^ self importFrom: (self class importFrom: aStream withMetamodel: self metamodel) named: (aStream localName removeSuffix: '.mse') + ^ self + importFrom: + (self class importFrom: aStream withMetamodel: self metamodel) + named: (aStream localName removeSuffix: '.mse') ] { #category : #actions } MooseModel >> importFromMSEStream: aStream filteredBy: anImportingContext [ + ^ self - importFrom: (self class importFrom: aStream withMetamodel: self metamodel filteredBy: anImportingContext) - named: (aStream localName removeSuffix: '.mse') + importFrom: (self class + importFrom: aStream + withMetamodel: self metamodel + filteredBy: anImportingContext) + named: (aStream localName removeSuffix: '.mse') ] { #category : #testing } @@ -814,16 +840,16 @@ MooseModel >> rootFolder: aString [ ] { #category : #'entity collection' } -MooseModel >> silentlyAdd: anElement [ - - self suspendAllAnnouncementsDuring: [^self add: anElement]. +MooseModel >> silentlyAdd: anElement [ + + self suspendAllAnnouncementsDuring: [ ^ self add: anElement ] ] { #category : #'entity collection' } -MooseModel >> silentlyAddAll: entities [ - - entities do: [:each | self addNoAnnounce: each]. - ^entities +MooseModel >> silentlyAddAll: entities [ + + entities do: [ :each | self addNoAnnounce: each ]. + ^ entities ] { #category : #'entity collection' } @@ -833,11 +859,10 @@ MooseModel >> silentlyRemove: anElement [ ] { #category : #'entity collection' } -MooseModel >> silentlyRemoveAll: collection [ - - collection do: [:each | self silentlyRemove: each]. - ^collection - +MooseModel >> silentlyRemoveAll: collection [ + + collection do: [ :each | self silentlyRemove: each ]. + ^ collection ] { #category : #'set operations' } From 5d2556360056541b5f536bf973103dd6f33ff3c5 Mon Sep 17 00:00:00 2001 From: ClotildeToullec Date: Thu, 9 Feb 2023 16:27:31 +0100 Subject: [PATCH 2/8] Generate new #shouldIgnore methods --- .../FamixJavaImportingContext.class.st | 78 +++++++++---------- .../FamixMetamodelBuilder.class.st | 4 +- .../FamixStImportingContext.class.st | 54 ++++++------- .../FamixTest1ImportingContext.class.st | 34 ++++---- 4 files changed, 85 insertions(+), 85 deletions(-) diff --git a/src/Famix-Java-Entities/FamixJavaImportingContext.class.st b/src/Famix-Java-Entities/FamixJavaImportingContext.class.st index 9c1271100..6f573945b 100644 --- a/src/Famix-Java-Entities/FamixJavaImportingContext.class.st +++ b/src/Famix-Java-Entities/FamixJavaImportingContext.class.st @@ -287,233 +287,233 @@ FamixJavaImportingContext >> importUnknownVariable [ { #category : #testing } FamixJavaImportingContext >> shouldImportAccess [ - ^ self shouldImport: FamixJavaAccess + ^ self shouldImport: #Access ] { #category : #testing } FamixJavaImportingContext >> shouldImportAnnotationInstance [ - ^ self shouldImport: FamixJavaAnnotationInstance + ^ self shouldImport: #AnnotationInstance ] { #category : #testing } FamixJavaImportingContext >> shouldImportAnnotationInstanceAttribute [ - ^ self shouldImport: FamixJavaAnnotationInstanceAttribute + ^ self shouldImport: #AnnotationInstanceAttribute ] { #category : #testing } FamixJavaImportingContext >> shouldImportAnnotationType [ - ^ self shouldImport: FamixJavaAnnotationType + ^ self shouldImport: #AnnotationType ] { #category : #testing } FamixJavaImportingContext >> shouldImportAnnotationTypeAttribute [ - ^ self shouldImport: FamixJavaAnnotationTypeAttribute + ^ self shouldImport: #AnnotationTypeAttribute ] { #category : #testing } FamixJavaImportingContext >> shouldImportAttribute [ - ^ self shouldImport: FamixJavaAttribute + ^ self shouldImport: #Attribute ] { #category : #testing } FamixJavaImportingContext >> shouldImportClass [ - ^ self shouldImport: FamixJavaClass + ^ self shouldImport: #Class ] { #category : #testing } FamixJavaImportingContext >> shouldImportComment [ - ^ self shouldImport: FamixJavaComment + ^ self shouldImport: #Comment ] { #category : #testing } FamixJavaImportingContext >> shouldImportContainerEntity [ - ^ self shouldImport: FamixJavaContainerEntity + ^ self shouldImport: #ContainerEntity ] { #category : #testing } FamixJavaImportingContext >> shouldImportEntity [ - ^ self shouldImport: FamixJavaEntity + ^ self shouldImport: #Entity ] { #category : #testing } FamixJavaImportingContext >> shouldImportEnum [ - ^ self shouldImport: FamixJavaEnum + ^ self shouldImport: #Enum ] { #category : #testing } FamixJavaImportingContext >> shouldImportEnumValue [ - ^ self shouldImport: FamixJavaEnumValue + ^ self shouldImport: #EnumValue ] { #category : #testing } FamixJavaImportingContext >> shouldImportException [ - ^ self shouldImport: FamixJavaException + ^ self shouldImport: #Exception ] { #category : #testing } FamixJavaImportingContext >> shouldImportImplementation [ - ^ self shouldImport: FamixJavaImplementation + ^ self shouldImport: #Implementation ] { #category : #testing } FamixJavaImportingContext >> shouldImportImplicitVariable [ - ^ self shouldImport: FamixJavaImplicitVariable + ^ self shouldImport: #ImplicitVariable ] { #category : #testing } FamixJavaImportingContext >> shouldImportImport [ - ^ self shouldImport: FamixJavaImport + ^ self shouldImport: #Import ] { #category : #testing } FamixJavaImportingContext >> shouldImportIndexedFileAnchor [ - ^ self shouldImport: FamixJavaIndexedFileAnchor + ^ self shouldImport: #IndexedFileAnchor ] { #category : #testing } FamixJavaImportingContext >> shouldImportInheritance [ - ^ self shouldImport: FamixJavaInheritance + ^ self shouldImport: #Inheritance ] { #category : #testing } FamixJavaImportingContext >> shouldImportInterface [ - ^ self shouldImport: FamixJavaInterface + ^ self shouldImport: #Interface ] { #category : #testing } FamixJavaImportingContext >> shouldImportInvocation [ - ^ self shouldImport: FamixJavaInvocation + ^ self shouldImport: #Invocation ] { #category : #testing } FamixJavaImportingContext >> shouldImportLocalVariable [ - ^ self shouldImport: FamixJavaLocalVariable + ^ self shouldImport: #LocalVariable ] { #category : #testing } FamixJavaImportingContext >> shouldImportMethod [ - ^ self shouldImport: FamixJavaMethod + ^ self shouldImport: #Method ] { #category : #testing } FamixJavaImportingContext >> shouldImportNamedEntity [ - ^ self shouldImport: FamixJavaNamedEntity + ^ self shouldImport: #NamedEntity ] { #category : #testing } FamixJavaImportingContext >> shouldImportPackage [ - ^ self shouldImport: FamixJavaPackage + ^ self shouldImport: #Package ] { #category : #testing } FamixJavaImportingContext >> shouldImportParameter [ - ^ self shouldImport: FamixJavaParameter + ^ self shouldImport: #Parameter ] { #category : #testing } FamixJavaImportingContext >> shouldImportParameterType [ - ^ self shouldImport: FamixJavaParameterType + ^ self shouldImport: #ParameterType ] { #category : #testing } FamixJavaImportingContext >> shouldImportParameterizableClass [ - ^ self shouldImport: FamixJavaParameterizableClass + ^ self shouldImport: #ParameterizableClass ] { #category : #testing } FamixJavaImportingContext >> shouldImportParameterizableException [ - ^ self shouldImport: FamixJavaParameterizableException + ^ self shouldImport: #ParameterizableException ] { #category : #testing } FamixJavaImportingContext >> shouldImportParameterizableInterface [ - ^ self shouldImport: FamixJavaParameterizableInterface + ^ self shouldImport: #ParameterizableInterface ] { #category : #testing } FamixJavaImportingContext >> shouldImportParameterizedType [ - ^ self shouldImport: FamixJavaParameterizedType + ^ self shouldImport: #ParameterizedType ] { #category : #testing } FamixJavaImportingContext >> shouldImportPrimitiveType [ - ^ self shouldImport: FamixJavaPrimitiveType + ^ self shouldImport: #PrimitiveType ] { #category : #testing } FamixJavaImportingContext >> shouldImportReference [ - ^ self shouldImport: FamixJavaReference + ^ self shouldImport: #Reference ] { #category : #testing } FamixJavaImportingContext >> shouldImportSourceAnchor [ - ^ self shouldImport: FamixJavaSourceAnchor + ^ self shouldImport: #SourceAnchor ] { #category : #testing } FamixJavaImportingContext >> shouldImportSourceLanguage [ - ^ self shouldImport: FamixJavaSourceLanguage + ^ self shouldImport: #SourceLanguage ] { #category : #testing } FamixJavaImportingContext >> shouldImportSourceTextAnchor [ - ^ self shouldImport: FamixJavaSourceTextAnchor + ^ self shouldImport: #SourceTextAnchor ] { #category : #testing } FamixJavaImportingContext >> shouldImportSourcedEntity [ - ^ self shouldImport: FamixJavaSourcedEntity + ^ self shouldImport: #SourcedEntity ] { #category : #testing } FamixJavaImportingContext >> shouldImportType [ - ^ self shouldImport: FamixJavaType + ^ self shouldImport: #Type ] { #category : #testing } FamixJavaImportingContext >> shouldImportUnknownSourceLanguage [ - ^ self shouldImport: FamixJavaUnknownSourceLanguage + ^ self shouldImport: #UnknownSourceLanguage ] { #category : #testing } FamixJavaImportingContext >> shouldImportUnknownVariable [ - ^ self shouldImport: FamixJavaUnknownVariable + ^ self shouldImport: #UnknownVariable ] diff --git a/src/Famix-MetamodelBuilder-Core/FamixMetamodelBuilder.class.st b/src/Famix-MetamodelBuilder-Core/FamixMetamodelBuilder.class.st index 4b0817bd1..377c8bd7f 100644 --- a/src/Famix-MetamodelBuilder-Core/FamixMetamodelBuilder.class.st +++ b/src/Famix-MetamodelBuilder-Core/FamixMetamodelBuilder.class.st @@ -243,9 +243,9 @@ FamixMetamodelBuilder >> generateShouldImportIn: contextClass [ self environment compile: ('shouldImport{1} - ^ self shouldImport: {2}' format: { + ^ self shouldImport: #{2}' format: { each name. - each fullName }) + each name }) in: contextClass classified: 'testing' ] ] ] diff --git a/src/Famix-PharoSmalltalk-Entities/FamixStImportingContext.class.st b/src/Famix-PharoSmalltalk-Entities/FamixStImportingContext.class.st index c65a92b83..f934c784f 100644 --- a/src/Famix-PharoSmalltalk-Entities/FamixStImportingContext.class.st +++ b/src/Famix-PharoSmalltalk-Entities/FamixStImportingContext.class.st @@ -203,161 +203,161 @@ FamixStImportingContext >> importUnknownVariable [ { #category : #testing } FamixStImportingContext >> shouldImportAccess [ - ^ self shouldImport: FamixStAccess + ^ self shouldImport: #Access ] { #category : #testing } FamixStImportingContext >> shouldImportAnnotationInstance [ - ^ self shouldImport: FamixStAnnotationInstance + ^ self shouldImport: #AnnotationInstance ] { #category : #testing } FamixStImportingContext >> shouldImportAnnotationInstanceAttribute [ - ^ self shouldImport: FamixStAnnotationInstanceAttribute + ^ self shouldImport: #AnnotationInstanceAttribute ] { #category : #testing } FamixStImportingContext >> shouldImportAnnotationType [ - ^ self shouldImport: FamixStAnnotationType + ^ self shouldImport: #AnnotationType ] { #category : #testing } FamixStImportingContext >> shouldImportAnnotationTypeAttribute [ - ^ self shouldImport: FamixStAnnotationTypeAttribute + ^ self shouldImport: #AnnotationTypeAttribute ] { #category : #testing } FamixStImportingContext >> shouldImportAttribute [ - ^ self shouldImport: FamixStAttribute + ^ self shouldImport: #Attribute ] { #category : #testing } FamixStImportingContext >> shouldImportClass [ - ^ self shouldImport: FamixStClass + ^ self shouldImport: #Class ] { #category : #testing } FamixStImportingContext >> shouldImportComment [ - ^ self shouldImport: FamixStComment + ^ self shouldImport: #Comment ] { #category : #testing } FamixStImportingContext >> shouldImportEntity [ - ^ self shouldImport: FamixStEntity + ^ self shouldImport: #Entity ] { #category : #testing } FamixStImportingContext >> shouldImportGlobalVariable [ - ^ self shouldImport: FamixStGlobalVariable + ^ self shouldImport: #GlobalVariable ] { #category : #testing } FamixStImportingContext >> shouldImportImplicitVariable [ - ^ self shouldImport: FamixStImplicitVariable + ^ self shouldImport: #ImplicitVariable ] { #category : #testing } FamixStImportingContext >> shouldImportInheritance [ - ^ self shouldImport: FamixStInheritance + ^ self shouldImport: #Inheritance ] { #category : #testing } FamixStImportingContext >> shouldImportInvocation [ - ^ self shouldImport: FamixStInvocation + ^ self shouldImport: #Invocation ] { #category : #testing } FamixStImportingContext >> shouldImportLocalVariable [ - ^ self shouldImport: FamixStLocalVariable + ^ self shouldImport: #LocalVariable ] { #category : #testing } FamixStImportingContext >> shouldImportMethod [ - ^ self shouldImport: FamixStMethod + ^ self shouldImport: #Method ] { #category : #testing } FamixStImportingContext >> shouldImportNamedEntity [ - ^ self shouldImport: FamixStNamedEntity + ^ self shouldImport: #NamedEntity ] { #category : #testing } FamixStImportingContext >> shouldImportNamespace [ - ^ self shouldImport: FamixStNamespace + ^ self shouldImport: #Namespace ] { #category : #testing } FamixStImportingContext >> shouldImportPackage [ - ^ self shouldImport: FamixStPackage + ^ self shouldImport: #Package ] { #category : #testing } FamixStImportingContext >> shouldImportParameter [ - ^ self shouldImport: FamixStParameter + ^ self shouldImport: #Parameter ] { #category : #testing } FamixStImportingContext >> shouldImportPharoEntitySourceAnchor [ - ^ self shouldImport: FamixStPharoEntitySourceAnchor + ^ self shouldImport: #PharoEntitySourceAnchor ] { #category : #testing } FamixStImportingContext >> shouldImportReference [ - ^ self shouldImport: FamixStReference + ^ self shouldImport: #Reference ] { #category : #testing } FamixStImportingContext >> shouldImportSourceAnchor [ - ^ self shouldImport: FamixStSourceAnchor + ^ self shouldImport: #SourceAnchor ] { #category : #testing } FamixStImportingContext >> shouldImportSourceLanguage [ - ^ self shouldImport: FamixStSourceLanguage + ^ self shouldImport: #SourceLanguage ] { #category : #testing } FamixStImportingContext >> shouldImportSourceTextAnchor [ - ^ self shouldImport: FamixStSourceTextAnchor + ^ self shouldImport: #SourceTextAnchor ] { #category : #testing } FamixStImportingContext >> shouldImportSourcedEntity [ - ^ self shouldImport: FamixStSourcedEntity + ^ self shouldImport: #SourcedEntity ] { #category : #testing } FamixStImportingContext >> shouldImportUnknownSourceLanguage [ - ^ self shouldImport: FamixStUnknownSourceLanguage + ^ self shouldImport: #UnknownSourceLanguage ] { #category : #testing } FamixStImportingContext >> shouldImportUnknownVariable [ - ^ self shouldImport: FamixStUnknownVariable + ^ self shouldImport: #UnknownVariable ] diff --git a/src/Famix-Test1-Entities/FamixTest1ImportingContext.class.st b/src/Famix-Test1-Entities/FamixTest1ImportingContext.class.st index eaa537e92..016b46306 100644 --- a/src/Famix-Test1-Entities/FamixTest1ImportingContext.class.st +++ b/src/Famix-Test1-Entities/FamixTest1ImportingContext.class.st @@ -133,101 +133,101 @@ FamixTest1ImportingContext >> importUnknownSourceLanguage [ { #category : #testing } FamixTest1ImportingContext >> shouldImportAssociation [ - ^ self shouldImport: FamixTest1Association + ^ self shouldImport: #Association ] { #category : #testing } FamixTest1ImportingContext >> shouldImportAttribute [ - ^ self shouldImport: FamixTest1Attribute + ^ self shouldImport: #Attribute ] { #category : #testing } FamixTest1ImportingContext >> shouldImportClass [ - ^ self shouldImport: FamixTest1Class + ^ self shouldImport: #Class ] { #category : #testing } FamixTest1ImportingContext >> shouldImportComment [ - ^ self shouldImport: FamixTest1Comment + ^ self shouldImport: #Comment ] { #category : #testing } FamixTest1ImportingContext >> shouldImportEntity [ - ^ self shouldImport: FamixTest1Entity + ^ self shouldImport: #Entity ] { #category : #testing } FamixTest1ImportingContext >> shouldImportFile [ - ^ self shouldImport: FamixTest1File + ^ self shouldImport: #File ] { #category : #testing } FamixTest1ImportingContext >> shouldImportFileAnchor [ - ^ self shouldImport: FamixTest1FileAnchor + ^ self shouldImport: #FileAnchor ] { #category : #testing } FamixTest1ImportingContext >> shouldImportFolder [ - ^ self shouldImport: FamixTest1Folder + ^ self shouldImport: #Folder ] { #category : #testing } FamixTest1ImportingContext >> shouldImportIndexedFileAnchor [ - ^ self shouldImport: FamixTest1IndexedFileAnchor + ^ self shouldImport: #IndexedFileAnchor ] { #category : #testing } FamixTest1ImportingContext >> shouldImportMethod [ - ^ self shouldImport: FamixTest1Method + ^ self shouldImport: #Method ] { #category : #testing } FamixTest1ImportingContext >> shouldImportMultipleFileAnchor [ - ^ self shouldImport: FamixTest1MultipleFileAnchor + ^ self shouldImport: #MultipleFileAnchor ] { #category : #testing } FamixTest1ImportingContext >> shouldImportNamedEntity [ - ^ self shouldImport: FamixTest1NamedEntity + ^ self shouldImport: #NamedEntity ] { #category : #testing } FamixTest1ImportingContext >> shouldImportSourceAnchor [ - ^ self shouldImport: FamixTest1SourceAnchor + ^ self shouldImport: #SourceAnchor ] { #category : #testing } FamixTest1ImportingContext >> shouldImportSourceLanguage [ - ^ self shouldImport: FamixTest1SourceLanguage + ^ self shouldImport: #SourceLanguage ] { #category : #testing } FamixTest1ImportingContext >> shouldImportSourceTextAnchor [ - ^ self shouldImport: FamixTest1SourceTextAnchor + ^ self shouldImport: #SourceTextAnchor ] { #category : #testing } FamixTest1ImportingContext >> shouldImportSourcedEntity [ - ^ self shouldImport: FamixTest1SourcedEntity + ^ self shouldImport: #SourcedEntity ] { #category : #testing } FamixTest1ImportingContext >> shouldImportUnknownSourceLanguage [ - ^ self shouldImport: FamixTest1UnknownSourceLanguage + ^ self shouldImport: #UnknownSourceLanguage ] From a3eed2d3ce8eca16f282dbbb4b430b3437b45bae Mon Sep 17 00:00:00 2001 From: ClotildeToullec Date: Thu, 9 Feb 2023 16:28:00 +0100 Subject: [PATCH 3/8] Use new Fame methods --- src/Moose-Core/FmxImportingContext.class.st | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/Moose-Core/FmxImportingContext.class.st b/src/Moose-Core/FmxImportingContext.class.st index 85ac971cc..f299b1eb5 100644 --- a/src/Moose-Core/FmxImportingContext.class.st +++ b/src/Moose-Core/FmxImportingContext.class.st @@ -13,14 +13,9 @@ Class { { #category : #'importing-filters' } FmxImportingContext >> containersOf: aFM3Class [ - | allMetamodelClasses | - allMetamodelClasses := self class importedMetamodel classes. - ^ aFM3Class allContainerProperties flatCollectAsSet: [ :prop | prop type isFM3Trait - ifTrue: [ - allMetamodelClasses select: [ :fm3Class | - fm3Class traits includes: prop type ] ] + ifTrue: [ prop type classUsers ] ifFalse: [ { prop type } ] ] ] @@ -48,19 +43,18 @@ FmxImportingContext >> import: aFM3Class traversed: traversedClasses [ { #category : #'importing-filters' } FmxImportingContext >> importMaximum [ - (self class methods - select: [ :m | m selector beginsWith: #import ] - thenCollect: #selector) \ #( importMaximum ) do: [ :aSelector | - self perform: aSelector ] + self imports: self class importedMetamodel classes ] { #category : #accessing } FmxImportingContext >> imports [ + ^ imports ] { #category : #accessing } FmxImportingContext >> imports: anObject [ + imports := anObject ] @@ -68,8 +62,7 @@ FmxImportingContext >> imports: anObject [ FmxImportingContext >> initialize [ super initialize. - - imports := Set new. + imports := Set new ] { #category : #testing } From d8d2163b6c007cb7ea82b8e812a870c1f18fb1d4 Mon Sep 17 00:00:00 2001 From: ClotildeToullec Date: Wed, 15 Feb 2023 16:03:32 +0100 Subject: [PATCH 4/8] Manage associations and concrete entities differently --- src/Famix-Deprecated/Object.extension.st | 9 +- .../FamixJavaImportingContext.class.st | 117 +++++++++----- .../FamixMetamodelBuilder.class.st | 50 ++++-- .../FamixStImportingContext.class.st | 81 ++++++---- .../FamixTest1ImportingContext.class.st | 51 ++++-- src/Moose-Core/FmxImportingContext.class.st | 145 ++++++++++++++---- 6 files changed, 324 insertions(+), 129 deletions(-) diff --git a/src/Famix-Deprecated/Object.extension.st b/src/Famix-Deprecated/Object.extension.st index ce7a896b3..21a3cd90c 100644 --- a/src/Famix-Deprecated/Object.extension.st +++ b/src/Famix-Deprecated/Object.extension.st @@ -2,8 +2,11 @@ Extension { #name : #Object } { #category : #'*Famix-Deprecated' } Object >> mooseDescriptionIn: aMetamodel [ + self - deprecated: 'Use aMetamodel descriptionOf: self class instanceSide instad' - transformWith: '`@receiver mooseDescriptionIn: `@arg' -> '`@arg descriptionOf: self class instanceSide'. - ^ aMetamodel descriptionOf: self class instanceSide + deprecated: + 'Use aMetamodel descriptionOf: self class instanceSide instad' + transformWith: '`@receiver mooseDescriptionIn: `@arg' + -> '`@arg descriptionOf: self class instanceSide'. + ^ aMetamodel fmTypeOf: self class instanceSide ] diff --git a/src/Famix-Java-Entities/FamixJavaImportingContext.class.st b/src/Famix-Java-Entities/FamixJavaImportingContext.class.st index 6f573945b..a1112bb85 100644 --- a/src/Famix-Java-Entities/FamixJavaImportingContext.class.st +++ b/src/Famix-Java-Entities/FamixJavaImportingContext.class.st @@ -15,505 +15,544 @@ FamixJavaImportingContext class >> importedMetamodel [ FamixJavaImportingContext >> importAccess [ - ^ self import: #Access + ^ self importAssociation: (self class fm3ClassNamed: #Access) ] { #category : #importing } FamixJavaImportingContext >> importAnnotationInstance [ - ^ self import: #AnnotationInstance + ^ self importConcreteEntity: (self class fm3ClassNamed: #AnnotationInstance) ] { #category : #importing } FamixJavaImportingContext >> importAnnotationInstanceAttribute [ - ^ self import: #AnnotationInstanceAttribute + ^ self importConcreteEntity: (self class fm3ClassNamed: #AnnotationInstanceAttribute) ] { #category : #importing } FamixJavaImportingContext >> importAnnotationType [ - ^ self import: #AnnotationType + ^ self importConcreteEntity: (self class fm3ClassNamed: #AnnotationType) ] { #category : #importing } FamixJavaImportingContext >> importAnnotationTypeAttribute [ - ^ self import: #AnnotationTypeAttribute + ^ self importConcreteEntity: (self class fm3ClassNamed: #AnnotationTypeAttribute) ] { #category : #importing } FamixJavaImportingContext >> importAttribute [ - ^ self import: #Attribute + ^ self importConcreteEntity: (self class fm3ClassNamed: #Attribute) ] { #category : #importing } FamixJavaImportingContext >> importClass [ - ^ self import: #Class + ^ self importConcreteEntity: (self class fm3ClassNamed: #Class) ] { #category : #importing } FamixJavaImportingContext >> importComment [ - ^ self import: #Comment + ^ self importConcreteEntity: (self class fm3ClassNamed: #Comment) ] { #category : #importing } FamixJavaImportingContext >> importContainerEntity [ - ^ self import: #ContainerEntity + ^ self importConcreteEntity: (self class fm3ClassNamed: #ContainerEntity) ] { #category : #importing } FamixJavaImportingContext >> importEntity [ - ^ self import: #Entity + ^ self importConcreteEntity: (self class fm3ClassNamed: #Entity) ] { #category : #importing } FamixJavaImportingContext >> importEnum [ - ^ self import: #Enum + ^ self importConcreteEntity: (self class fm3ClassNamed: #Enum) ] { #category : #importing } FamixJavaImportingContext >> importEnumValue [ - ^ self import: #EnumValue + ^ self importConcreteEntity: (self class fm3ClassNamed: #EnumValue) ] { #category : #importing } FamixJavaImportingContext >> importException [ - ^ self import: #Exception + ^ self importConcreteEntity: (self class fm3ClassNamed: #Exception) ] { #category : #importing } FamixJavaImportingContext >> importImplementation [ - ^ self import: #Implementation + ^ self importAssociation: (self class fm3ClassNamed: #Implementation) ] { #category : #importing } FamixJavaImportingContext >> importImplicitVariable [ - ^ self import: #ImplicitVariable + ^ self importConcreteEntity: (self class fm3ClassNamed: #ImplicitVariable) ] { #category : #importing } FamixJavaImportingContext >> importImport [ - ^ self import: #Import + ^ self importAssociation: (self class fm3ClassNamed: #Import) ] { #category : #importing } FamixJavaImportingContext >> importIndexedFileAnchor [ - ^ self import: #IndexedFileAnchor + ^ self importConcreteEntity: (self class fm3ClassNamed: #IndexedFileAnchor) ] { #category : #importing } FamixJavaImportingContext >> importInheritance [ - ^ self import: #Inheritance + ^ self importAssociation: (self class fm3ClassNamed: #Inheritance) ] { #category : #importing } FamixJavaImportingContext >> importInterface [ - ^ self import: #Interface + ^ self importConcreteEntity: (self class fm3ClassNamed: #Interface) ] { #category : #importing } FamixJavaImportingContext >> importInvocation [ - ^ self import: #Invocation + ^ self importAssociation: (self class fm3ClassNamed: #Invocation) ] { #category : #importing } FamixJavaImportingContext >> importLocalVariable [ - ^ self import: #LocalVariable + ^ self importConcreteEntity: (self class fm3ClassNamed: #LocalVariable) ] { #category : #importing } FamixJavaImportingContext >> importMethod [ - ^ self import: #Method + ^ self importConcreteEntity: (self class fm3ClassNamed: #Method) ] { #category : #importing } FamixJavaImportingContext >> importNamedEntity [ - ^ self import: #NamedEntity + ^ self importConcreteEntity: (self class fm3ClassNamed: #NamedEntity) ] { #category : #importing } FamixJavaImportingContext >> importPackage [ - ^ self import: #Package + ^ self importConcreteEntity: (self class fm3ClassNamed: #Package) ] { #category : #importing } FamixJavaImportingContext >> importParameter [ - ^ self import: #Parameter + ^ self importConcreteEntity: (self class fm3ClassNamed: #Parameter) ] { #category : #importing } FamixJavaImportingContext >> importParameterType [ - ^ self import: #ParameterType + ^ self importConcreteEntity: (self class fm3ClassNamed: #ParameterType) ] { #category : #importing } FamixJavaImportingContext >> importParameterizableClass [ - ^ self import: #ParameterizableClass + ^ self importConcreteEntity: (self class fm3ClassNamed: #ParameterizableClass) ] { #category : #importing } FamixJavaImportingContext >> importParameterizableException [ - ^ self import: #ParameterizableException + ^ self importConcreteEntity: (self class fm3ClassNamed: #ParameterizableException) ] { #category : #importing } FamixJavaImportingContext >> importParameterizableInterface [ - ^ self import: #ParameterizableInterface + ^ self importConcreteEntity: (self class fm3ClassNamed: #ParameterizableInterface) ] { #category : #importing } FamixJavaImportingContext >> importParameterizedType [ - ^ self import: #ParameterizedType + ^ self importConcreteEntity: (self class fm3ClassNamed: #ParameterizedType) ] { #category : #importing } FamixJavaImportingContext >> importPrimitiveType [ - ^ self import: #PrimitiveType + ^ self importConcreteEntity: (self class fm3ClassNamed: #PrimitiveType) ] { #category : #importing } FamixJavaImportingContext >> importReference [ - ^ self import: #Reference + ^ self importAssociation: (self class fm3ClassNamed: #Reference) ] { #category : #importing } FamixJavaImportingContext >> importSourceAnchor [ - ^ self import: #SourceAnchor + ^ self importConcreteEntity: (self class fm3ClassNamed: #SourceAnchor) ] { #category : #importing } FamixJavaImportingContext >> importSourceLanguage [ - ^ self import: #SourceLanguage + ^ self importConcreteEntity: (self class fm3ClassNamed: #SourceLanguage) ] { #category : #importing } FamixJavaImportingContext >> importSourceTextAnchor [ - ^ self import: #SourceTextAnchor + ^ self importConcreteEntity: (self class fm3ClassNamed: #SourceTextAnchor) ] { #category : #importing } FamixJavaImportingContext >> importSourcedEntity [ - ^ self import: #SourcedEntity + ^ self importConcreteEntity: (self class fm3ClassNamed: #SourcedEntity) ] { #category : #importing } FamixJavaImportingContext >> importType [ - ^ self import: #Type + ^ self importConcreteEntity: (self class fm3ClassNamed: #Type) ] { #category : #importing } FamixJavaImportingContext >> importUnknownSourceLanguage [ - ^ self import: #UnknownSourceLanguage + ^ self importConcreteEntity: (self class fm3ClassNamed: #UnknownSourceLanguage) ] { #category : #importing } FamixJavaImportingContext >> importUnknownVariable [ - ^ self import: #UnknownVariable + ^ self importConcreteEntity: (self class fm3ClassNamed: #UnknownVariable) ] { #category : #testing } FamixJavaImportingContext >> shouldImportAccess [ + ^ self shouldImport: #Access ] { #category : #testing } FamixJavaImportingContext >> shouldImportAnnotationInstance [ + ^ self shouldImport: #AnnotationInstance ] { #category : #testing } FamixJavaImportingContext >> shouldImportAnnotationInstanceAttribute [ + ^ self shouldImport: #AnnotationInstanceAttribute ] { #category : #testing } FamixJavaImportingContext >> shouldImportAnnotationType [ + ^ self shouldImport: #AnnotationType ] { #category : #testing } FamixJavaImportingContext >> shouldImportAnnotationTypeAttribute [ + ^ self shouldImport: #AnnotationTypeAttribute ] { #category : #testing } FamixJavaImportingContext >> shouldImportAttribute [ + ^ self shouldImport: #Attribute ] { #category : #testing } FamixJavaImportingContext >> shouldImportClass [ + ^ self shouldImport: #Class ] { #category : #testing } FamixJavaImportingContext >> shouldImportComment [ + ^ self shouldImport: #Comment ] { #category : #testing } FamixJavaImportingContext >> shouldImportContainerEntity [ + ^ self shouldImport: #ContainerEntity ] { #category : #testing } FamixJavaImportingContext >> shouldImportEntity [ + ^ self shouldImport: #Entity ] { #category : #testing } FamixJavaImportingContext >> shouldImportEnum [ + ^ self shouldImport: #Enum ] { #category : #testing } FamixJavaImportingContext >> shouldImportEnumValue [ + ^ self shouldImport: #EnumValue ] { #category : #testing } FamixJavaImportingContext >> shouldImportException [ + ^ self shouldImport: #Exception ] { #category : #testing } FamixJavaImportingContext >> shouldImportImplementation [ + ^ self shouldImport: #Implementation ] { #category : #testing } FamixJavaImportingContext >> shouldImportImplicitVariable [ + ^ self shouldImport: #ImplicitVariable ] { #category : #testing } FamixJavaImportingContext >> shouldImportImport [ + ^ self shouldImport: #Import ] { #category : #testing } FamixJavaImportingContext >> shouldImportIndexedFileAnchor [ + ^ self shouldImport: #IndexedFileAnchor ] { #category : #testing } FamixJavaImportingContext >> shouldImportInheritance [ + ^ self shouldImport: #Inheritance ] { #category : #testing } FamixJavaImportingContext >> shouldImportInterface [ + ^ self shouldImport: #Interface ] { #category : #testing } FamixJavaImportingContext >> shouldImportInvocation [ + ^ self shouldImport: #Invocation ] { #category : #testing } FamixJavaImportingContext >> shouldImportLocalVariable [ + ^ self shouldImport: #LocalVariable ] { #category : #testing } FamixJavaImportingContext >> shouldImportMethod [ + ^ self shouldImport: #Method ] { #category : #testing } FamixJavaImportingContext >> shouldImportNamedEntity [ + ^ self shouldImport: #NamedEntity ] { #category : #testing } FamixJavaImportingContext >> shouldImportPackage [ + ^ self shouldImport: #Package ] { #category : #testing } FamixJavaImportingContext >> shouldImportParameter [ + ^ self shouldImport: #Parameter ] { #category : #testing } FamixJavaImportingContext >> shouldImportParameterType [ + ^ self shouldImport: #ParameterType ] { #category : #testing } FamixJavaImportingContext >> shouldImportParameterizableClass [ + ^ self shouldImport: #ParameterizableClass ] { #category : #testing } FamixJavaImportingContext >> shouldImportParameterizableException [ + ^ self shouldImport: #ParameterizableException ] { #category : #testing } FamixJavaImportingContext >> shouldImportParameterizableInterface [ + ^ self shouldImport: #ParameterizableInterface ] { #category : #testing } FamixJavaImportingContext >> shouldImportParameterizedType [ + ^ self shouldImport: #ParameterizedType ] { #category : #testing } FamixJavaImportingContext >> shouldImportPrimitiveType [ + ^ self shouldImport: #PrimitiveType ] { #category : #testing } FamixJavaImportingContext >> shouldImportReference [ + ^ self shouldImport: #Reference ] { #category : #testing } FamixJavaImportingContext >> shouldImportSourceAnchor [ + ^ self shouldImport: #SourceAnchor ] { #category : #testing } FamixJavaImportingContext >> shouldImportSourceLanguage [ + ^ self shouldImport: #SourceLanguage ] { #category : #testing } FamixJavaImportingContext >> shouldImportSourceTextAnchor [ + ^ self shouldImport: #SourceTextAnchor ] { #category : #testing } FamixJavaImportingContext >> shouldImportSourcedEntity [ + ^ self shouldImport: #SourcedEntity ] { #category : #testing } FamixJavaImportingContext >> shouldImportType [ + ^ self shouldImport: #Type ] { #category : #testing } FamixJavaImportingContext >> shouldImportUnknownSourceLanguage [ + ^ self shouldImport: #UnknownSourceLanguage ] { #category : #testing } FamixJavaImportingContext >> shouldImportUnknownVariable [ + ^ self shouldImport: #UnknownVariable ] diff --git a/src/Famix-MetamodelBuilder-Core/FamixMetamodelBuilder.class.st b/src/Famix-MetamodelBuilder-Core/FamixMetamodelBuilder.class.st index 377c8bd7f..7a8b900c0 100644 --- a/src/Famix-MetamodelBuilder-Core/FamixMetamodelBuilder.class.st +++ b/src/Famix-MetamodelBuilder-Core/FamixMetamodelBuilder.class.st @@ -183,19 +183,44 @@ FamixMetamodelBuilder >> generate [ ] { #category : #generating } -FamixMetamodelBuilder >> generateImportIn: contextClass [ +FamixMetamodelBuilder >> generateImportAssociation: aFmxMBAssociationClass in: contextClass [ - self classes do: [ :each | "No need to generate methods for model class." - each isModelClass ifFalse: [ - self environment - compile: ('import{1} + ^ self environment + compile: ('import{1} - ^ self import: #{2}' format: { - each name. - each name }) - in: contextClass - classified: 'importing' ] ] + ^ self importAssociation: (self class fm3ClassNamed: #{1})' format: + { aFmxMBAssociationClass name }) + in: contextClass + classified: 'importing' +] + +{ #category : #generating } +FamixMetamodelBuilder >> generateImportConcreteEntity: aFmxMBClass in: contextClass [ + + ^ self environment + compile: ('import{1} + + + ^ self importConcreteEntity: (self class fm3ClassNamed: #{1})' + format: { aFmxMBClass name }) + in: contextClass + classified: 'importing' +] + +{ #category : #generating } +FamixMetamodelBuilder >> generateImportIn: contextClass [ + + self classes do: [ :each | + + "No need to generate methods for model class." + each isModelClass ifFalse: [ + + "Associations and other entities are managed differently by the importing context" + each allTransitiveTraits + detect: [ :trait | trait name = #TAssociation ] + ifFound: [ self generateImportAssociation: each in: contextClass ] + ifNone: [ self generateImportConcreteEntity: each in: contextClass ] ] ] ] { #category : #generating } @@ -242,10 +267,9 @@ FamixMetamodelBuilder >> generateShouldImportIn: contextClass [ each isModelClass ifFalse: [ self environment compile: ('shouldImport{1} + - ^ self shouldImport: #{2}' format: { - each name. - each name }) + ^ self shouldImport: #{1}' format: { each name }) in: contextClass classified: 'testing' ] ] ] diff --git a/src/Famix-PharoSmalltalk-Entities/FamixStImportingContext.class.st b/src/Famix-PharoSmalltalk-Entities/FamixStImportingContext.class.st index f934c784f..60cba4d81 100644 --- a/src/Famix-PharoSmalltalk-Entities/FamixStImportingContext.class.st +++ b/src/Famix-PharoSmalltalk-Entities/FamixStImportingContext.class.st @@ -15,349 +15,376 @@ FamixStImportingContext class >> importedMetamodel [ FamixStImportingContext >> importAccess [ - ^ self import: #Access + ^ self importAssociation: (self class fm3ClassNamed: #Access) ] { #category : #importing } FamixStImportingContext >> importAnnotationInstance [ - ^ self import: #AnnotationInstance + ^ self importConcreteEntity: (self class fm3ClassNamed: #AnnotationInstance) ] { #category : #importing } FamixStImportingContext >> importAnnotationInstanceAttribute [ - ^ self import: #AnnotationInstanceAttribute + ^ self importConcreteEntity: (self class fm3ClassNamed: #AnnotationInstanceAttribute) ] { #category : #importing } FamixStImportingContext >> importAnnotationType [ - ^ self import: #AnnotationType + ^ self importConcreteEntity: (self class fm3ClassNamed: #AnnotationType) ] { #category : #importing } FamixStImportingContext >> importAnnotationTypeAttribute [ - ^ self import: #AnnotationTypeAttribute + ^ self importConcreteEntity: (self class fm3ClassNamed: #AnnotationTypeAttribute) ] { #category : #importing } FamixStImportingContext >> importAttribute [ - ^ self import: #Attribute + ^ self importConcreteEntity: (self class fm3ClassNamed: #Attribute) ] { #category : #importing } FamixStImportingContext >> importClass [ - ^ self import: #Class + ^ self importConcreteEntity: (self class fm3ClassNamed: #Class) ] { #category : #importing } FamixStImportingContext >> importComment [ - ^ self import: #Comment + ^ self importConcreteEntity: (self class fm3ClassNamed: #Comment) ] { #category : #importing } FamixStImportingContext >> importEntity [ - ^ self import: #Entity + ^ self importConcreteEntity: (self class fm3ClassNamed: #Entity) ] { #category : #importing } FamixStImportingContext >> importGlobalVariable [ - ^ self import: #GlobalVariable + ^ self importConcreteEntity: (self class fm3ClassNamed: #GlobalVariable) ] { #category : #importing } FamixStImportingContext >> importImplicitVariable [ - ^ self import: #ImplicitVariable + ^ self importConcreteEntity: (self class fm3ClassNamed: #ImplicitVariable) ] { #category : #importing } FamixStImportingContext >> importInheritance [ - ^ self import: #Inheritance + ^ self importAssociation: (self class fm3ClassNamed: #Inheritance) ] { #category : #importing } FamixStImportingContext >> importInvocation [ - ^ self import: #Invocation + ^ self importAssociation: (self class fm3ClassNamed: #Invocation) ] { #category : #importing } FamixStImportingContext >> importLocalVariable [ - ^ self import: #LocalVariable + ^ self importConcreteEntity: (self class fm3ClassNamed: #LocalVariable) ] { #category : #importing } FamixStImportingContext >> importMethod [ - ^ self import: #Method + ^ self importConcreteEntity: (self class fm3ClassNamed: #Method) ] { #category : #importing } FamixStImportingContext >> importNamedEntity [ - ^ self import: #NamedEntity + ^ self importConcreteEntity: (self class fm3ClassNamed: #NamedEntity) ] { #category : #importing } FamixStImportingContext >> importNamespace [ - ^ self import: #Namespace + ^ self importConcreteEntity: (self class fm3ClassNamed: #Namespace) ] { #category : #importing } FamixStImportingContext >> importPackage [ - ^ self import: #Package + ^ self importConcreteEntity: (self class fm3ClassNamed: #Package) ] { #category : #importing } FamixStImportingContext >> importParameter [ - ^ self import: #Parameter + ^ self importConcreteEntity: (self class fm3ClassNamed: #Parameter) ] { #category : #importing } FamixStImportingContext >> importPharoEntitySourceAnchor [ - ^ self import: #PharoEntitySourceAnchor + ^ self importConcreteEntity: (self class fm3ClassNamed: #PharoEntitySourceAnchor) ] { #category : #importing } FamixStImportingContext >> importReference [ - ^ self import: #Reference + ^ self importAssociation: (self class fm3ClassNamed: #Reference) ] { #category : #importing } FamixStImportingContext >> importSourceAnchor [ - ^ self import: #SourceAnchor + ^ self importConcreteEntity: (self class fm3ClassNamed: #SourceAnchor) ] { #category : #importing } FamixStImportingContext >> importSourceLanguage [ - ^ self import: #SourceLanguage + ^ self importConcreteEntity: (self class fm3ClassNamed: #SourceLanguage) ] { #category : #importing } FamixStImportingContext >> importSourceTextAnchor [ - ^ self import: #SourceTextAnchor + ^ self importConcreteEntity: (self class fm3ClassNamed: #SourceTextAnchor) ] { #category : #importing } FamixStImportingContext >> importSourcedEntity [ - ^ self import: #SourcedEntity + ^ self importConcreteEntity: (self class fm3ClassNamed: #SourcedEntity) ] { #category : #importing } FamixStImportingContext >> importUnknownSourceLanguage [ - ^ self import: #UnknownSourceLanguage + ^ self importConcreteEntity: (self class fm3ClassNamed: #UnknownSourceLanguage) ] { #category : #importing } FamixStImportingContext >> importUnknownVariable [ - ^ self import: #UnknownVariable + ^ self importConcreteEntity: (self class fm3ClassNamed: #UnknownVariable) ] { #category : #testing } FamixStImportingContext >> shouldImportAccess [ + ^ self shouldImport: #Access ] { #category : #testing } FamixStImportingContext >> shouldImportAnnotationInstance [ + ^ self shouldImport: #AnnotationInstance ] { #category : #testing } FamixStImportingContext >> shouldImportAnnotationInstanceAttribute [ + ^ self shouldImport: #AnnotationInstanceAttribute ] { #category : #testing } FamixStImportingContext >> shouldImportAnnotationType [ + ^ self shouldImport: #AnnotationType ] { #category : #testing } FamixStImportingContext >> shouldImportAnnotationTypeAttribute [ + ^ self shouldImport: #AnnotationTypeAttribute ] { #category : #testing } FamixStImportingContext >> shouldImportAttribute [ + ^ self shouldImport: #Attribute ] { #category : #testing } FamixStImportingContext >> shouldImportClass [ + ^ self shouldImport: #Class ] { #category : #testing } FamixStImportingContext >> shouldImportComment [ + ^ self shouldImport: #Comment ] { #category : #testing } FamixStImportingContext >> shouldImportEntity [ + ^ self shouldImport: #Entity ] { #category : #testing } FamixStImportingContext >> shouldImportGlobalVariable [ + ^ self shouldImport: #GlobalVariable ] { #category : #testing } FamixStImportingContext >> shouldImportImplicitVariable [ + ^ self shouldImport: #ImplicitVariable ] { #category : #testing } FamixStImportingContext >> shouldImportInheritance [ + ^ self shouldImport: #Inheritance ] { #category : #testing } FamixStImportingContext >> shouldImportInvocation [ + ^ self shouldImport: #Invocation ] { #category : #testing } FamixStImportingContext >> shouldImportLocalVariable [ + ^ self shouldImport: #LocalVariable ] { #category : #testing } FamixStImportingContext >> shouldImportMethod [ + ^ self shouldImport: #Method ] { #category : #testing } FamixStImportingContext >> shouldImportNamedEntity [ + ^ self shouldImport: #NamedEntity ] { #category : #testing } FamixStImportingContext >> shouldImportNamespace [ + ^ self shouldImport: #Namespace ] { #category : #testing } FamixStImportingContext >> shouldImportPackage [ + ^ self shouldImport: #Package ] { #category : #testing } FamixStImportingContext >> shouldImportParameter [ + ^ self shouldImport: #Parameter ] { #category : #testing } FamixStImportingContext >> shouldImportPharoEntitySourceAnchor [ + ^ self shouldImport: #PharoEntitySourceAnchor ] { #category : #testing } FamixStImportingContext >> shouldImportReference [ + ^ self shouldImport: #Reference ] { #category : #testing } FamixStImportingContext >> shouldImportSourceAnchor [ + ^ self shouldImport: #SourceAnchor ] { #category : #testing } FamixStImportingContext >> shouldImportSourceLanguage [ + ^ self shouldImport: #SourceLanguage ] { #category : #testing } FamixStImportingContext >> shouldImportSourceTextAnchor [ + ^ self shouldImport: #SourceTextAnchor ] { #category : #testing } FamixStImportingContext >> shouldImportSourcedEntity [ + ^ self shouldImport: #SourcedEntity ] { #category : #testing } FamixStImportingContext >> shouldImportUnknownSourceLanguage [ + ^ self shouldImport: #UnknownSourceLanguage ] { #category : #testing } FamixStImportingContext >> shouldImportUnknownVariable [ + ^ self shouldImport: #UnknownVariable ] diff --git a/src/Famix-Test1-Entities/FamixTest1ImportingContext.class.st b/src/Famix-Test1-Entities/FamixTest1ImportingContext.class.st index 016b46306..4337aff95 100644 --- a/src/Famix-Test1-Entities/FamixTest1ImportingContext.class.st +++ b/src/Famix-Test1-Entities/FamixTest1ImportingContext.class.st @@ -15,219 +15,236 @@ FamixTest1ImportingContext class >> importedMetamodel [ FamixTest1ImportingContext >> importAssociation [ - ^ self import: #Association + ^ self importAssociation: (self class fm3ClassNamed: #Association) ] { #category : #importing } FamixTest1ImportingContext >> importAttribute [ - ^ self import: #Attribute + ^ self importConcreteEntity: (self class fm3ClassNamed: #Attribute) ] { #category : #importing } FamixTest1ImportingContext >> importClass [ - ^ self import: #Class + ^ self importConcreteEntity: (self class fm3ClassNamed: #Class) ] { #category : #importing } FamixTest1ImportingContext >> importComment [ - ^ self import: #Comment + ^ self importConcreteEntity: (self class fm3ClassNamed: #Comment) ] { #category : #importing } FamixTest1ImportingContext >> importEntity [ - ^ self import: #Entity + ^ self importConcreteEntity: (self class fm3ClassNamed: #Entity) ] { #category : #importing } FamixTest1ImportingContext >> importFile [ - ^ self import: #File + ^ self importConcreteEntity: (self class fm3ClassNamed: #File) ] { #category : #importing } FamixTest1ImportingContext >> importFileAnchor [ - ^ self import: #FileAnchor + ^ self importConcreteEntity: (self class fm3ClassNamed: #FileAnchor) ] { #category : #importing } FamixTest1ImportingContext >> importFolder [ - ^ self import: #Folder + ^ self importConcreteEntity: (self class fm3ClassNamed: #Folder) ] { #category : #importing } FamixTest1ImportingContext >> importIndexedFileAnchor [ - ^ self import: #IndexedFileAnchor + ^ self importConcreteEntity: (self class fm3ClassNamed: #IndexedFileAnchor) ] { #category : #importing } FamixTest1ImportingContext >> importMethod [ - ^ self import: #Method + ^ self importConcreteEntity: (self class fm3ClassNamed: #Method) ] { #category : #importing } FamixTest1ImportingContext >> importMultipleFileAnchor [ - ^ self import: #MultipleFileAnchor + ^ self importConcreteEntity: (self class fm3ClassNamed: #MultipleFileAnchor) ] { #category : #importing } FamixTest1ImportingContext >> importNamedEntity [ - ^ self import: #NamedEntity + ^ self importConcreteEntity: (self class fm3ClassNamed: #NamedEntity) ] { #category : #importing } FamixTest1ImportingContext >> importSourceAnchor [ - ^ self import: #SourceAnchor + ^ self importConcreteEntity: (self class fm3ClassNamed: #SourceAnchor) ] { #category : #importing } FamixTest1ImportingContext >> importSourceLanguage [ - ^ self import: #SourceLanguage + ^ self importConcreteEntity: (self class fm3ClassNamed: #SourceLanguage) ] { #category : #importing } FamixTest1ImportingContext >> importSourceTextAnchor [ - ^ self import: #SourceTextAnchor + ^ self importConcreteEntity: (self class fm3ClassNamed: #SourceTextAnchor) ] { #category : #importing } FamixTest1ImportingContext >> importSourcedEntity [ - ^ self import: #SourcedEntity + ^ self importConcreteEntity: (self class fm3ClassNamed: #SourcedEntity) ] { #category : #importing } FamixTest1ImportingContext >> importUnknownSourceLanguage [ - ^ self import: #UnknownSourceLanguage + ^ self importConcreteEntity: (self class fm3ClassNamed: #UnknownSourceLanguage) ] { #category : #testing } FamixTest1ImportingContext >> shouldImportAssociation [ + ^ self shouldImport: #Association ] { #category : #testing } FamixTest1ImportingContext >> shouldImportAttribute [ + ^ self shouldImport: #Attribute ] { #category : #testing } FamixTest1ImportingContext >> shouldImportClass [ + ^ self shouldImport: #Class ] { #category : #testing } FamixTest1ImportingContext >> shouldImportComment [ + ^ self shouldImport: #Comment ] { #category : #testing } FamixTest1ImportingContext >> shouldImportEntity [ + ^ self shouldImport: #Entity ] { #category : #testing } FamixTest1ImportingContext >> shouldImportFile [ + ^ self shouldImport: #File ] { #category : #testing } FamixTest1ImportingContext >> shouldImportFileAnchor [ + ^ self shouldImport: #FileAnchor ] { #category : #testing } FamixTest1ImportingContext >> shouldImportFolder [ + ^ self shouldImport: #Folder ] { #category : #testing } FamixTest1ImportingContext >> shouldImportIndexedFileAnchor [ + ^ self shouldImport: #IndexedFileAnchor ] { #category : #testing } FamixTest1ImportingContext >> shouldImportMethod [ + ^ self shouldImport: #Method ] { #category : #testing } FamixTest1ImportingContext >> shouldImportMultipleFileAnchor [ + ^ self shouldImport: #MultipleFileAnchor ] { #category : #testing } FamixTest1ImportingContext >> shouldImportNamedEntity [ + ^ self shouldImport: #NamedEntity ] { #category : #testing } FamixTest1ImportingContext >> shouldImportSourceAnchor [ + ^ self shouldImport: #SourceAnchor ] { #category : #testing } FamixTest1ImportingContext >> shouldImportSourceLanguage [ + ^ self shouldImport: #SourceLanguage ] { #category : #testing } FamixTest1ImportingContext >> shouldImportSourceTextAnchor [ + ^ self shouldImport: #SourceTextAnchor ] { #category : #testing } FamixTest1ImportingContext >> shouldImportSourcedEntity [ + ^ self shouldImport: #SourcedEntity ] { #category : #testing } FamixTest1ImportingContext >> shouldImportUnknownSourceLanguage [ + ^ self shouldImport: #UnknownSourceLanguage ] diff --git a/src/Moose-Core/FmxImportingContext.class.st b/src/Moose-Core/FmxImportingContext.class.st index f299b1eb5..839bac23f 100644 --- a/src/Moose-Core/FmxImportingContext.class.st +++ b/src/Moose-Core/FmxImportingContext.class.st @@ -5,68 +5,153 @@ Class { #name : #FmxImportingContext, #superclass : #Object, #instVars : [ - 'imports' + 'importedAssociations', + 'allMetamodelConcreteEntities', + 'allMetamodelAssociations', + 'importedEntities' ], - #category : #'Moose-Core' + #category : #'Moose-Core-Import' } -{ #category : #'importing-filters' } -FmxImportingContext >> containersOf: aFM3Class [ +{ #category : #accessing } +FmxImportingContext class >> allMetamodelAssociations [ + + ^ (self importedMetamodel traits detect: [ :trait | + trait name = #TAssociation ]) classUsers +] + +{ #category : #accessing } +FmxImportingContext class >> allMetamodelEntities [ - ^ aFM3Class allContainerProperties flatCollectAsSet: [ :prop | - prop type isFM3Trait - ifTrue: [ prop type classUsers ] - ifFalse: [ { prop type } ] ] + ^ self importedMetamodel classes reject: [ :fm3Class | + fm3Class traits anySatisfy: [ :fm3Trait | + fm3Trait name = #TAssociation ] ] ] -{ #category : #'importing-filters' } -FmxImportingContext >> import: aClassName [ +{ #category : #accessing } +FmxImportingContext class >> fm3ClassNamed: aName [ - self - import: (self class importedMetamodel elements detect: [ :e | - e name = aClassName ]) - traversed: Set new + ^ self importedMetamodel classes detect: [ :fm3Class | + fm3Class name = aName ] ] -{ #category : #'importing-filters' } -FmxImportingContext >> import: aFM3Class traversed: traversedClasses [ +{ #category : #accessing } +FmxImportingContext class >> importedMetamodel [ - (traversedClasses includes: aFM3Class) ifTrue: [ ^ self ]. + ^ self subclassResponsibility +] - self imports add: aFM3Class. - traversedClasses add: aFM3Class. +{ #category : #'importing-remove' } +FmxImportingContext >> doNotImportAssociation: aFM3AssociationClass [ - (self containersOf: aFM3Class) do: [ :fm3Behavior | - self import: fm3Behavior traversed: traversedClasses ] + importedAssociations remove: aFM3AssociationClass ifAbsent: [ ] ] -{ #category : #'importing-filters' } +{ #category : #'importing-remove' } +FmxImportingContext >> doNotImportAssociationsDependingOn: aFM3Class [ + + aFM3Class allProperties + select: [ :prop | + importedAssociations includesAny: prop type classUsers ] + thenDo: [ :prop | + prop type classUsers do: [ :fm3Class | + self doNotImportAssociation: fm3Class ] ] +] + +{ #category : #'importing-remove' } +FmxImportingContext >> doNotImportConcreteEntity: aFM3Class [ + + self importedEntities remove: aFM3Class ifAbsent: [ ^ self ]. + + self doNotImportEntitiesContainedIn: aFM3Class. + self doNotImportAssociationsDependingOn: aFM3Class +] + +{ #category : #'importing-remove' } +FmxImportingContext >> doNotImportEntitiesContainedIn: aFM3Class [ + + aFM3Class allComplexProperties + select: [ :property | + property hasOpposite and: [ property opposite isContainer ] ] + thenDo: [ :property | + property type classUsers do: [ :fm3Class | + self doNotImportConcreteEntity: fm3Class ] ] +] + +{ #category : #'importing-all' } +FmxImportingContext >> importAllAssociations [ + + allMetamodelAssociations do: [ :association | + self importAssociation: association ] +] + +{ #category : #'importing-all' } +FmxImportingContext >> importAllEntities [ + + allMetamodelConcreteEntities do: [ :fm3Class | + self importConcreteEntity: fm3Class ] +] + +{ #category : #'importing-add' } +FmxImportingContext >> importAssociation: aFM3AssociationClass [ + + (importedAssociations includes: aFM3AssociationClass) ifTrue: [ + ^ self ]. + + importedAssociations add: aFM3AssociationClass. + + aFM3AssociationClass allComplexProperties + select: [ :property | property isSource or: [ property isTarget ] ] + thenDo: [ :property | + property type classUsers do: [ :fm3Class | + self importConcreteEntity: fm3Class ] ] +] + +{ #category : #'importing-add' } +FmxImportingContext >> importConcreteEntity: aFM3Class [ + + (self importedEntities includes: aFM3Class) ifTrue: [ ^ self ]. + + self importedEntities add: aFM3Class. + + aFM3Class allContainerProperties do: [ :containerProperty | + containerProperty type classUsers do: [ :fm3Class | + self importConcreteEntity: fm3Class ] ] +] + +{ #category : #'importing-all' } FmxImportingContext >> importMaximum [ - self imports: self class importedMetamodel classes + self importAllEntities. + self importAllAssociations ] { #category : #accessing } -FmxImportingContext >> imports [ +FmxImportingContext >> importedEntities [ - ^ imports + ^ importedEntities ] { #category : #accessing } -FmxImportingContext >> imports: anObject [ +FmxImportingContext >> imports [ - imports := anObject + ^ importedEntities , importedAssociations ] { #category : #initialization } FmxImportingContext >> initialize [ super initialize. - imports := Set new + importedEntities := Set new. + importedAssociations := Set new. + + allMetamodelAssociations := self class allMetamodelAssociations. + allMetamodelConcreteEntities := self class allMetamodelEntities ] { #category : #testing } -FmxImportingContext >> shouldImport: aClass [ +FmxImportingContext >> shouldImport: aClassName [ - ^ self imports includes: aClass + ^ (importedEntities includes: aClassName) or: [ + importedAssociations includes: aClassName ] ] From 47d2c39b71cd08a7d0eebb49165f8fc75b48c6ba Mon Sep 17 00:00:00 2001 From: ClotildeToullec Date: Fri, 17 Feb 2023 12:29:30 +0100 Subject: [PATCH 5/8] Fisrt version of a UI --- .../FamixMetamodelBuilder.class.st | 9 +- src/Moose-Core/FmxImportingContext.class.st | 19 ++- src/Moose-Core/FmxImportingPresenter.class.st | 143 ++++++++++++++++++ 3 files changed, 165 insertions(+), 6 deletions(-) create mode 100644 src/Moose-Core/FmxImportingPresenter.class.st diff --git a/src/Famix-MetamodelBuilder-Core/FamixMetamodelBuilder.class.st b/src/Famix-MetamodelBuilder-Core/FamixMetamodelBuilder.class.st index 7a8b900c0..9d6150528 100644 --- a/src/Famix-MetamodelBuilder-Core/FamixMetamodelBuilder.class.st +++ b/src/Famix-MetamodelBuilder-Core/FamixMetamodelBuilder.class.st @@ -213,14 +213,15 @@ FamixMetamodelBuilder >> generateImportIn: contextClass [ self classes do: [ :each | - "No need to generate methods for model class." - each isModelClass ifFalse: [ - + "No need to generate methods for model class and groups." + (each isModelClass or: [ each isMetamodelClassGroup ]) ifFalse: [ + "Associations and other entities are managed differently by the importing context" each allTransitiveTraits detect: [ :trait | trait name = #TAssociation ] ifFound: [ self generateImportAssociation: each in: contextClass ] - ifNone: [ self generateImportConcreteEntity: each in: contextClass ] ] ] + ifNone: [ + self generateImportConcreteEntity: each in: contextClass ] ] ] ] { #category : #generating } diff --git a/src/Moose-Core/FmxImportingContext.class.st b/src/Moose-Core/FmxImportingContext.class.st index 839bac23f..6f593aa9d 100644 --- a/src/Moose-Core/FmxImportingContext.class.st +++ b/src/Moose-Core/FmxImportingContext.class.st @@ -24,8 +24,10 @@ FmxImportingContext class >> allMetamodelAssociations [ FmxImportingContext class >> allMetamodelEntities [ ^ self importedMetamodel classes reject: [ :fm3Class | - fm3Class traits anySatisfy: [ :fm3Trait | - fm3Trait name = #TAssociation ] ] + (fm3Class inheritsFrom: + (self importedMetamodel fmTypeOf: MooseAbstractGroup)) or: [ + fm3Class traits anySatisfy: [ :fm3Trait | + fm3Trait name = #TAssociation ] ] ] ] { #category : #accessing } @@ -126,6 +128,19 @@ FmxImportingContext >> importMaximum [ self importAllAssociations ] +{ #category : #'importing-remove' } +FmxImportingContext >> importNone [ + + importedAssociations := Set new. + importedEntities := Set new +] + +{ #category : #accessing } +FmxImportingContext >> importedAssociations [ + + ^ importedAssociations +] + { #category : #accessing } FmxImportingContext >> importedEntities [ diff --git a/src/Moose-Core/FmxImportingPresenter.class.st b/src/Moose-Core/FmxImportingPresenter.class.st new file mode 100644 index 000000000..ac075e3ae --- /dev/null +++ b/src/Moose-Core/FmxImportingPresenter.class.st @@ -0,0 +1,143 @@ +Class { + #name : #FmxImportingPresenter, + #superclass : #SpPresenter, + #instVars : [ + 'importingContext', + 'entitiesList', + 'associationList', + 'toolbar' + ], + #category : #'Moose-Core-Import' +} + +{ #category : #initialization } +FmxImportingPresenter class >> numberOfEntitiesPerColumn [ + + ^ 15 +] + +{ #category : #specs } +FmxImportingPresenter class >> title [ + + ^ 'Select entities to be imported in your model' +] + +{ #category : #specs } +FmxImportingPresenter class >> windowSize [ + + ^ 600 @ 400 +] + +{ #category : #initialization } +FmxImportingPresenter >> initializeAssociationsList [ + + associationList := self instantiate: + SpFilteringSelectableListPresenter. + + associationList + items: importingContext importedAssociations asArray; + display: #name; + onActivation: [ :fm3Class | + fm3Class ifNotNil: [ + importingContext importAssociation: fm3Class. + self updateSelection ] ]; + onDeactivation: [ :fm3Class | + fm3Class ifNotNil: [ + importingContext doNotImportAssociation: fm3Class. + self updateSelection ] ]. + + associationList listPresenter sortingBlock: [ :a :b | + a name < b name ] +] + +{ #category : #initialization } +FmxImportingPresenter >> initializeEntitiesList [ + + entitiesList := self instantiate: SpFilteringSelectableListPresenter. + entitiesList + items: importingContext importedEntities asArray; + display: #name; + onActivation: [ :fm3Class | + fm3Class ifNotNil: [ + importingContext importConcreteEntity: fm3Class. + self updateSelection ] ]; + onDeactivation: [ :fm3Class | + fm3Class ifNotNil: [ + importingContext doNotImportConcreteEntity: fm3Class. + self updateSelection ] ]. + + entitiesList listPresenter sortingBlock: [ :a :b | a name < b name ] +] + +{ #category : #initialization } +FmxImportingPresenter >> initializeLayout [ + + self layout: (SpBoxLayout newVertical + add: toolbar expand: false; + add: (SpBoxLayout newLeftToRight + add: (SpBoxLayout newVertical + add: 'Associations' expand: false; + add: associationList; + yourself); + spacing: 5; + add: (SpBoxLayout newVertical + add: 'Entities' expand: false; + add: entitiesList; + yourself); + yourself); + yourself) +] + +{ #category : #initialization } +FmxImportingPresenter >> initializePresenters [ + + self initializeToolbar. + self initializeAssociationsList. + self initializeEntitiesList. + self initializeLayout. + self updateSelection +] + +{ #category : #initialization } +FmxImportingPresenter >> initializeToolbar [ + + toolbar := self newToolbar. + toolbar + add: (self newToolbarButton + label: 'Select All'; + icon: (self iconNamed: #checkedBox); + action: [ + importingContext importMaximum. + self updateSelection ]); + add: (self newToolbarButton + label: 'Unselect All'; + icon: (self iconNamed: #uncheckedBox); + action: [ + importingContext importNone. + self updateSelection ]) +] + +{ #category : #initialization } +FmxImportingPresenter >> initializeWindow: aWindowPresenter [ + + aWindowPresenter + title: self class title; + initialExtent: self class windowSize +] + +{ #category : #'accessing - model' } +FmxImportingPresenter >> setModelBeforeInitialization: aFmxImportingContext [ + + importingContext := aFmxImportingContext +] + +{ #category : #initialization } +FmxImportingPresenter >> updateSelection [ + + associationList + selectItems: Set new; + selectItems: importingContext importedAssociations copy. + entitiesList + selectItems: Set new; + selectItems: importingContext importedEntities copy +] From 317582dc522bd35d221a49f1e2d9971fb6afbaca Mon Sep 17 00:00:00 2001 From: ClotildeToullec Date: Fri, 3 Mar 2023 11:05:15 +0100 Subject: [PATCH 6/8] Generate an accessor for Importing context class in MooseModels --- .../FamixJavaModel.class.st | 7 ++ .../FamixMetamodelBuilder.class.st | 18 ++++- .../FamixStModel.class.st | 7 ++ .../FamixTest1Model.class.st | 7 ++ src/Moose-Core/FmxImportingPresenter.class.st | 8 +- src/Moose-Core/MooseGroupStorage.class.st | 9 ++- .../CandidateListOperator.class.st | 40 ++++++---- .../InstallElementsOperator.class.st | 37 ++++----- .../MooseCompositeImporterTask.class.st | 2 +- .../SmalltalkImporter.class.st | 77 ++++++++++--------- 10 files changed, 131 insertions(+), 81 deletions(-) diff --git a/src/Famix-Java-Entities/FamixJavaModel.class.st b/src/Famix-Java-Entities/FamixJavaModel.class.st index b4a4f7633..ed78fdd8f 100644 --- a/src/Famix-Java-Entities/FamixJavaModel.class.st +++ b/src/Famix-Java-Entities/FamixJavaModel.class.st @@ -23,6 +23,13 @@ FamixJavaModel class >> canBeImportedFromFile [ ^true ] +{ #category : #accessing } +FamixJavaModel class >> importingContextClass [ + + + ^ FamixJavaImportingContext +] + { #category : #'as yet unclassified' } FamixJavaModel >> inferPackageParentsBasedOnNames [ diff --git a/src/Famix-MetamodelBuilder-Core/FamixMetamodelBuilder.class.st b/src/Famix-MetamodelBuilder-Core/FamixMetamodelBuilder.class.st index 9d6150528..9d71bd07e 100644 --- a/src/Famix-MetamodelBuilder-Core/FamixMetamodelBuilder.class.st +++ b/src/Famix-MetamodelBuilder-Core/FamixMetamodelBuilder.class.st @@ -182,6 +182,18 @@ FamixMetamodelBuilder >> generate [ self apply ] +{ #category : #generating } +FamixMetamodelBuilder >> generateContextClassMethodInModel [ + + self environment + compile: ('importingContextClass + + + ^ {1}' format: { self importingContextName }) + in: self model realClass classSide + classified: 'accessing' +] + { #category : #generating } FamixMetamodelBuilder >> generateImportAssociation: aFmxMBAssociationClass in: contextClass [ @@ -237,7 +249,9 @@ FamixMetamodelBuilder >> generateImportingContext [ self generateImportingContextMetamodelIn: contextClass. self generateShouldImportIn: contextClass. - self generateImportIn: contextClass + self generateImportIn: contextClass. + + self generateContextClassMethodInModel ] { #category : #generating } @@ -265,7 +279,7 @@ FamixMetamodelBuilder >> generateRemotes [ FamixMetamodelBuilder >> generateShouldImportIn: contextClass [ self classes do: [ :each | "No need to generate methods for model class." - each isModelClass ifFalse: [ + (each isModelClass or: [ each isMetamodelClassGroup ]) ifFalse: [ self environment compile: ('shouldImport{1} diff --git a/src/Famix-PharoSmalltalk-Entities/FamixStModel.class.st b/src/Famix-PharoSmalltalk-Entities/FamixStModel.class.st index 6fac93fef..82b71b381 100644 --- a/src/Famix-PharoSmalltalk-Entities/FamixStModel.class.st +++ b/src/Famix-PharoSmalltalk-Entities/FamixStModel.class.st @@ -22,3 +22,10 @@ FamixStModel class >> canBeImportedFromFile [ ^true ] + +{ #category : #accessing } +FamixStModel class >> importingContextClass [ + + + ^ FamixStImportingContext +] diff --git a/src/Famix-Test1-Entities/FamixTest1Model.class.st b/src/Famix-Test1-Entities/FamixTest1Model.class.st index 0bb2ce3e7..ac3d44355 100644 --- a/src/Famix-Test1-Entities/FamixTest1Model.class.st +++ b/src/Famix-Test1-Entities/FamixTest1Model.class.st @@ -23,6 +23,13 @@ FamixTest1Model class >> annotation [ ] +{ #category : #accessing } +FamixTest1Model class >> importingContextClass [ + + + ^ FamixTest1ImportingContext +] + { #category : #accessing } FamixTest1Model >> modelHasProperties [ diff --git a/src/Moose-Core/FmxImportingPresenter.class.st b/src/Moose-Core/FmxImportingPresenter.class.st index ac075e3ae..382c8e886 100644 --- a/src/Moose-Core/FmxImportingPresenter.class.st +++ b/src/Moose-Core/FmxImportingPresenter.class.st @@ -23,7 +23,7 @@ FmxImportingPresenter class >> title [ ] { #category : #specs } -FmxImportingPresenter class >> windowSize [ +FmxImportingPresenter class >> windowExtent [ ^ 600 @ 400 ] @@ -105,13 +105,13 @@ FmxImportingPresenter >> initializeToolbar [ toolbar add: (self newToolbarButton label: 'Select All'; - icon: (self iconNamed: #checkedBox); + icon: (self iconNamed: #smallAdd); action: [ importingContext importMaximum. self updateSelection ]); add: (self newToolbarButton label: 'Unselect All'; - icon: (self iconNamed: #uncheckedBox); + icon: (self iconNamed: #smallDelete); action: [ importingContext importNone. self updateSelection ]) @@ -122,7 +122,7 @@ FmxImportingPresenter >> initializeWindow: aWindowPresenter [ aWindowPresenter title: self class title; - initialExtent: self class windowSize + initialExtent: self class windowExtent ] { #category : #'accessing - model' } diff --git a/src/Moose-Core/MooseGroupStorage.class.st b/src/Moose-Core/MooseGroupStorage.class.st index ff9506225..bcd8fd97f 100644 --- a/src/Moose-Core/MooseGroupStorage.class.st +++ b/src/Moose-Core/MooseGroupStorage.class.st @@ -67,12 +67,15 @@ MooseGroupStorage >> basicIterator [ ] { #category : #private } -MooseGroupStorage >> becomeKind: elementStorageClass [ - +MooseGroupStorage >> becomeKind: elementStorageClass [ + self class = elementStorageClass ifTrue: [ ^ self ]. - [elementStorageClass includesBehavior: MooseGroupStorage] assert. + + [ elementStorageClass includesBehavior: MooseGroupStorage ] assert. + self do: [ :each | each hasUniqueMooseNameInModel ifTrue: [ each privateClearMooseName ] ]. + self become: (elementStorageClass withAll: self) ] diff --git a/src/Moose-SmalltalkImporter/CandidateListOperator.class.st b/src/Moose-SmalltalkImporter/CandidateListOperator.class.st index 6a9854ba2..88de2764e 100644 --- a/src/Moose-SmalltalkImporter/CandidateListOperator.class.st +++ b/src/Moose-SmalltalkImporter/CandidateListOperator.class.st @@ -12,27 +12,33 @@ Class { } { #category : #running } -CandidateListOperator >> allCandidatesFor: invocation [ - ^Array - withAll: - (groups - at: invocation signature - ifAbsent: [ | stubs | - stubs := self importer ensureSmalltalkStubMethodsFor: invocation signature. - groups at: invocation signature put: stubs. - stubs do: [:each | model add: each]. - stubs ]) +CandidateListOperator >> allCandidatesFor: invocation [ + + ^ Array withAll: (groups at: invocation signature ifAbsent: [ + | stubs | + stubs := self importer ensureSmalltalkStubMethodsFor: + invocation signature. + groups at: invocation signature put: stubs. + stubs do: [ :each | model add: each. model add: each parentType ]. + stubs ]) ] { #category : #running } CandidateListOperator >> computeCandidateListFor: anInvocation [ - anInvocation receiver - ifNotNil: [ :receiver | - (receiver isImplicitVariable and: [ receiver isSuper ]) - ifTrue: [ ^ self computeCandidateListFor: anInvocation withBaseClass: receiver belongsTo parentType superclass ]. - (receiver isImplicitVariable and: [ receiver isSelf ]) - ifTrue: [ ^ self computeCandidateListFor: anInvocation withReceivingClass: receiver belongsTo parentType ]. - receiver isClass ifTrue: [ ^ self computeCandidateListFor: anInvocation withBaseClass: receiver ] ]. + + anInvocation receiver ifNotNil: [ :receiver | + (receiver isImplicitVariable and: [ receiver isSuper ]) ifTrue: [ + ^ self + computeCandidateListFor: anInvocation + withBaseClass: receiver belongsTo parentType superclass ]. + (receiver isImplicitVariable and: [ receiver isSelf ]) ifTrue: [ + ^ self + computeCandidateListFor: anInvocation + withReceivingClass: receiver belongsTo parentType ]. + receiver isClass ifTrue: [ + ^ self + computeCandidateListFor: anInvocation + withBaseClass: receiver ] ]. anInvocation candidates: (self allCandidatesFor: anInvocation) ] diff --git a/src/Moose-SmalltalkImporter/InstallElementsOperator.class.st b/src/Moose-SmalltalkImporter/InstallElementsOperator.class.st index ad89b741a..e7b0f9302 100644 --- a/src/Moose-SmalltalkImporter/InstallElementsOperator.class.st +++ b/src/Moose-SmalltalkImporter/InstallElementsOperator.class.st @@ -36,21 +36,22 @@ InstallElementsOperator class >> with: elements runOn: aMooseModel [ run ] -{ #category : #running } -InstallElementsOperator >> basicRun [ - model entityStorage forSetup. - self container - do: - [:each | - model add: each. - self increment]. +{ #category : #private } +InstallElementsOperator >> basicRun [ + + model entityStorage forSetup. + + self container do: [ :each | + model add: each. + self increment ]. + model entityStorage forRuntime ] { #category : #accessing } -InstallElementsOperator >> container [ - - ^container +InstallElementsOperator >> container [ + + ^ container ] { #category : #accessing } @@ -60,14 +61,14 @@ InstallElementsOperator >> container: anObject [ ] { #category : #accessing } -InstallElementsOperator >> description [ - - ^'Installing <1p> entities in Moose model' - expandMacrosWith: self container size +InstallElementsOperator >> description [ + + ^ 'Installing <1p> entities in Moose model' expandMacrosWith: + self container size ] { #category : #accessing } -InstallElementsOperator >> length [ - - ^self container size +InstallElementsOperator >> length [ + + ^ self container size ] diff --git a/src/Moose-SmalltalkImporter/MooseCompositeImporterTask.class.st b/src/Moose-SmalltalkImporter/MooseCompositeImporterTask.class.st index e7f3bf4b8..eb9e6e879 100644 --- a/src/Moose-SmalltalkImporter/MooseCompositeImporterTask.class.st +++ b/src/Moose-SmalltalkImporter/MooseCompositeImporterTask.class.st @@ -39,7 +39,7 @@ MooseCompositeImporterTask >> basicRun [ importerTask addAll: self allClasses. importerTask addAllExtensions: self allClassExtensions. importer := importerTask runSelector: runSelector. - "InstallElementsOperator populates a Moose model with (unary) elements" + "InstallElementsOperator populates a Moose model with (unary) elements" (InstallElementsOperator with: importer on: self model) runSelector: runSelector. "CandidateListOperator populates a Moose model with (binary) element relations like: methodA invokes methodB" candidateOperator ifTrue: [ (self candidateClass runOn: self model importer: importer) runSelector: runSelector ]. diff --git a/src/Moose-SmalltalkImporter/SmalltalkImporter.class.st b/src/Moose-SmalltalkImporter/SmalltalkImporter.class.st index 860488488..cf8451f0f 100644 --- a/src/Moose-SmalltalkImporter/SmalltalkImporter.class.st +++ b/src/Moose-SmalltalkImporter/SmalltalkImporter.class.st @@ -61,16 +61,17 @@ SmalltalkImporter >> allImplementorsOf: aSignature [ { #category : #'private-entity-creation' } SmalltalkImporter >> basicClassCreation: aClass [ + | class anchor | class := classes at: aClass put: self factory classEntity new. class name: (aClass name replaceAll: Character space with: $_). class stub: true. - importingContext shouldImportNamespace - ifTrue: [ class typeContainer: (self ensureNamespace: aClass environment) ]. + importingContext shouldImportNamespace ifTrue: [ + class typeContainer: (self ensureNamespace: aClass environment) ]. anchor := self factory anchor new - element: class; - pharoEntity: aClass; - yourself. + element: class; + pharoEntity: aClass; + yourself. class sourceAnchor: anchor. self addEntity: anchor. ^ class @@ -224,16 +225,17 @@ SmalltalkImporter >> createGlobalVariable: name value: value [ { #category : #'private-entity-creation' } SmalltalkImporter >> createMethod: aCompiledMethod [ + | method anchor | method := self createStubMethod: aCompiledMethod. - importingContext shouldImportMethodBody - ifTrue: [ | visitor | - visitor := SmalltalkMethodVisitor on: self. - visitor runWith: aCompiledMethod and: method ]. + importingContext shouldImportMethodBody ifTrue: [ + | visitor | + visitor := SmalltalkMethodVisitor on: self. + visitor runWith: aCompiledMethod and: method ]. anchor := self factory anchor new - element: method; - pharoEntity: aCompiledMethod; - yourself. + element: method; + pharoEntity: aCompiledMethod; + yourself. method sourceAnchor: anchor. self addEntity: anchor. ^ method @@ -357,12 +359,11 @@ SmalltalkImporter >> ensureAttribute: name for: aClass [ ] { #category : #'public-entity-creation' } -SmalltalkImporter >> ensureClass: aClass [ - "aClass is aSmalltalk. This method returns a FAMIXClass" - - ^classes - at: aClass - ifAbsent: [self createClass: aClass] +SmalltalkImporter >> ensureClass: aClass [ + + "aClass is aSmalltalk. This method returns a FamixStClass" + + ^ classes at: aClass ifAbsent: [ self createClass: aClass ] ] { #category : #'public-entity-creation' } @@ -432,22 +433,25 @@ SmalltalkImporter >> ensurePackage: aPackageModel [ ] { #category : #'public-entity-creation' } -SmalltalkImporter >> ensureSmalltalkStubMethod: aCompiledMethod [ - - ^methods - at: aCompiledMethod - ifAbsent: [self createStubMethod: aCompiledMethod] +SmalltalkImporter >> ensureSmalltalkStubMethod: aCompiledMethod [ + + ^ methods + at: aCompiledMethod + ifAbsent: [ self createStubMethod: aCompiledMethod ] ] { #category : #'public-entity-creation' } SmalltalkImporter >> ensureSmalltalkStubMethodsFor: aSignature [ + | implementors | - importingContext shouldImportSmalltalkStubMethod - ifFalse: [^#()]. + importingContext shouldImportSmalltalkStubMethod ifFalse: [ ^ #( ) ]. implementors := self allImplementorsOf: aSignature. - implementors ifEmpty: [ - ^{ self basicCreateMethod: (aSignature copyUpTo: $() withSignature: aSignature } ]. - ^ implementors collect: [ :meth | self ensureSmalltalkStubMethod: meth ] + implementors ifEmpty: [ + ^ { (self + basicCreateMethod: (aSignature copyUpTo: $() + withSignature: aSignature) } ]. + ^ implementors collect: [ :meth | + self ensureSmalltalkStubMethod: meth ] ] { #category : #'public-entity-creation' } @@ -501,14 +505,15 @@ SmalltalkImporter >> importClass: aClass [ ] { #category : #importing } -SmalltalkImporter >> importClassExtension: aClassExtension [ - - | method | - importingContext shouldImportClassExtension ifTrue: [ - method := (self ensureMethod: aClassExtension) isStub: false. - importingContext shouldImportPackage ifTrue: [ - method parentPackage isStub: false ]. - ] +SmalltalkImporter >> importClassExtension: aClassExtension [ + + | method | + importingContext shouldImportClassExtension ifFalse: [ ^ self ]. + + method := (self ensureMethod: aClassExtension) isStub: false. + + importingContext shouldImportPackage ifTrue: [ + method parentPackage isStub: false ] ] { #category : #initialization } From eeb9338f2e34088b1cb870f953778a6cb1978b3a Mon Sep 17 00:00:00 2001 From: ClotildeToullec Date: Fri, 3 Mar 2023 15:36:53 +0100 Subject: [PATCH 7/8] Move Presenter to MooseIDE --- src/Moose-Core/FmxImportingPresenter.class.st | 143 ------------------ 1 file changed, 143 deletions(-) delete mode 100644 src/Moose-Core/FmxImportingPresenter.class.st diff --git a/src/Moose-Core/FmxImportingPresenter.class.st b/src/Moose-Core/FmxImportingPresenter.class.st deleted file mode 100644 index 382c8e886..000000000 --- a/src/Moose-Core/FmxImportingPresenter.class.st +++ /dev/null @@ -1,143 +0,0 @@ -Class { - #name : #FmxImportingPresenter, - #superclass : #SpPresenter, - #instVars : [ - 'importingContext', - 'entitiesList', - 'associationList', - 'toolbar' - ], - #category : #'Moose-Core-Import' -} - -{ #category : #initialization } -FmxImportingPresenter class >> numberOfEntitiesPerColumn [ - - ^ 15 -] - -{ #category : #specs } -FmxImportingPresenter class >> title [ - - ^ 'Select entities to be imported in your model' -] - -{ #category : #specs } -FmxImportingPresenter class >> windowExtent [ - - ^ 600 @ 400 -] - -{ #category : #initialization } -FmxImportingPresenter >> initializeAssociationsList [ - - associationList := self instantiate: - SpFilteringSelectableListPresenter. - - associationList - items: importingContext importedAssociations asArray; - display: #name; - onActivation: [ :fm3Class | - fm3Class ifNotNil: [ - importingContext importAssociation: fm3Class. - self updateSelection ] ]; - onDeactivation: [ :fm3Class | - fm3Class ifNotNil: [ - importingContext doNotImportAssociation: fm3Class. - self updateSelection ] ]. - - associationList listPresenter sortingBlock: [ :a :b | - a name < b name ] -] - -{ #category : #initialization } -FmxImportingPresenter >> initializeEntitiesList [ - - entitiesList := self instantiate: SpFilteringSelectableListPresenter. - entitiesList - items: importingContext importedEntities asArray; - display: #name; - onActivation: [ :fm3Class | - fm3Class ifNotNil: [ - importingContext importConcreteEntity: fm3Class. - self updateSelection ] ]; - onDeactivation: [ :fm3Class | - fm3Class ifNotNil: [ - importingContext doNotImportConcreteEntity: fm3Class. - self updateSelection ] ]. - - entitiesList listPresenter sortingBlock: [ :a :b | a name < b name ] -] - -{ #category : #initialization } -FmxImportingPresenter >> initializeLayout [ - - self layout: (SpBoxLayout newVertical - add: toolbar expand: false; - add: (SpBoxLayout newLeftToRight - add: (SpBoxLayout newVertical - add: 'Associations' expand: false; - add: associationList; - yourself); - spacing: 5; - add: (SpBoxLayout newVertical - add: 'Entities' expand: false; - add: entitiesList; - yourself); - yourself); - yourself) -] - -{ #category : #initialization } -FmxImportingPresenter >> initializePresenters [ - - self initializeToolbar. - self initializeAssociationsList. - self initializeEntitiesList. - self initializeLayout. - self updateSelection -] - -{ #category : #initialization } -FmxImportingPresenter >> initializeToolbar [ - - toolbar := self newToolbar. - toolbar - add: (self newToolbarButton - label: 'Select All'; - icon: (self iconNamed: #smallAdd); - action: [ - importingContext importMaximum. - self updateSelection ]); - add: (self newToolbarButton - label: 'Unselect All'; - icon: (self iconNamed: #smallDelete); - action: [ - importingContext importNone. - self updateSelection ]) -] - -{ #category : #initialization } -FmxImportingPresenter >> initializeWindow: aWindowPresenter [ - - aWindowPresenter - title: self class title; - initialExtent: self class windowExtent -] - -{ #category : #'accessing - model' } -FmxImportingPresenter >> setModelBeforeInitialization: aFmxImportingContext [ - - importingContext := aFmxImportingContext -] - -{ #category : #initialization } -FmxImportingPresenter >> updateSelection [ - - associationList - selectItems: Set new; - selectItems: importingContext importedAssociations copy. - entitiesList - selectItems: Set new; - selectItems: importingContext importedEntities copy -] From 759be26b5130b00e2ea2fd4defbf0268834692f8 Mon Sep 17 00:00:00 2001 From: ClotildeToullec Date: Fri, 3 Mar 2023 16:15:31 +0100 Subject: [PATCH 8/8] Fixes --- .../FmxMBImportingContextTest.class.st | 10 +++++----- src/Moose-Core/MooseEntity.class.st | 17 ----------------- src/Moose-Core/MooseModel.class.st | 18 +++++++++++++++++- .../CandidateListOperator.class.st | 2 +- 4 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/Famix-MetamodelBuilder-Tests/FmxMBImportingContextTest.class.st b/src/Famix-MetamodelBuilder-Tests/FmxMBImportingContextTest.class.st index a303af4d8..26a451daf 100644 --- a/src/Famix-MetamodelBuilder-Tests/FmxMBImportingContextTest.class.st +++ b/src/Famix-MetamodelBuilder-Tests/FmxMBImportingContextTest.class.st @@ -41,8 +41,8 @@ FmxMBImportingContextTest >> testDefineImport [ localMethod := generatedContext methodNamed: #importMethod. self assert: (localMethod sourceCode includesSubstring: ''). - self assert: - (localMethod sourceCode includesSubstring: '^ self import: #Method') + self assert: (localMethod sourceCode includesSubstring: + 'self importConcreteEntity: (self class fm3ClassNamed: #Method') ] { #category : #tests } @@ -87,14 +87,14 @@ FmxMBImportingContextTest >> testShouldImport [ localMethod := generatedContext methodNamed: #shouldImportMethod. self assert: (localMethod sourceCode includesSubstring: ''). - self assert: (localMethod sourceCode includesSubstring: '^ self shouldImport: TstMethod'). + self assert: (localMethod sourceCode includesSubstring: '^ self shouldImport: #Method'). localMethod := generatedContext methodNamed: #shouldImportAccess. self assert: (localMethod sourceCode includesSubstring: ''). - self assert: (localMethod sourceCode includesSubstring: '^ self shouldImport: TstAccess'). + self assert: (localMethod sourceCode includesSubstring: '^ self shouldImport: #Access'). localMethod := generatedContext methodNamed: #shouldImportVariable. self assert: (localMethod sourceCode includesSubstring: ''). - self assert: (localMethod sourceCode includesSubstring: '^ self shouldImport: TstVariable'). + self assert: (localMethod sourceCode includesSubstring: '^ self shouldImport: #Variable'). ] diff --git a/src/Moose-Core/MooseEntity.class.st b/src/Moose-Core/MooseEntity.class.st index 3d8f32661..03f1e8bcb 100644 --- a/src/Moose-Core/MooseEntity.class.st +++ b/src/Moose-Core/MooseEntity.class.st @@ -68,23 +68,6 @@ MooseEntity class >> model: aMooseModel [ yourself ] -{ #category : #accessing } -MooseEntity class >> requirements [ - - | metamodelClasses usedBehaviors | - metamodelClasses := self metamodel concreteImplementingClasses. - - usedBehaviors := (self allDeclaredPropertiesIn: self metamodel) - select: #isContainer - thenCollect: [ :p | p opposite implementingClass ]. - - ^ (usedBehaviors flatCollect: [ :aBehavior | - aBehavior isTrait - ifTrue: [ - metamodelClasses select: [ :each | each isComposedBy: aBehavior ] ] - ifFalse: [ { aBehavior } ] ]) asSet -] - { #category : #dependencies } MooseEntity >> addAllChildrenDependenciesThrough: aDirectionStrategy in: aCollection [ aCollection addAll: (aDirectionStrategy dependenciesAtReceiverScopeOf: self). diff --git a/src/Moose-Core/MooseModel.class.st b/src/Moose-Core/MooseModel.class.st index 325cff655..2475bd5fe 100644 --- a/src/Moose-Core/MooseModel.class.st +++ b/src/Moose-Core/MooseModel.class.st @@ -218,6 +218,22 @@ MooseModel class >> importFromJSON: aStream withMetamodel: aMetamodel customizin ^ model ] +{ #category : #'import-export' } +MooseModel class >> importFromJSON: aStream withMetamodel: aMetamodel filteredBy: anImportingContext [ + + "In the way to import a model we filter the entites we want to import via a FmxImportContext." + + | famixElementNames | + famixElementNames := anImportingContext imports collect: [ :each | + each fullName ]. + + ^ self + importFromJSON: aStream + withMetamodel: aMetamodel + customizingImporterWith: [ :importer | + FMImporterFilter on: importer filtering: famixElementNames ] +] + { #category : #'import-export' } MooseModel class >> importFromMSEStream: aStream [ ^ self new @@ -561,7 +577,7 @@ MooseModel >> importFromJSONStream: aStream filteredBy: anImportingContext [ ^ self importFrom: (self class - importFrom: aStream + importFromJSON: aStream withMetamodel: self metamodel filteredBy: anImportingContext) named: (aStream localName removeSuffix: '.json') diff --git a/src/Moose-SmalltalkImporter/CandidateListOperator.class.st b/src/Moose-SmalltalkImporter/CandidateListOperator.class.st index 88de2764e..aa3fa5282 100644 --- a/src/Moose-SmalltalkImporter/CandidateListOperator.class.st +++ b/src/Moose-SmalltalkImporter/CandidateListOperator.class.st @@ -19,7 +19,7 @@ CandidateListOperator >> allCandidatesFor: invocation [ stubs := self importer ensureSmalltalkStubMethodsFor: invocation signature. groups at: invocation signature put: stubs. - stubs do: [ :each | model add: each. model add: each parentType ]. + stubs do: [ :each | model add: each ]. stubs ]) ]