From 28ad1fc34a141f63af11f030b8311ff4353be406 Mon Sep 17 00:00:00 2001 From: sofeess Date: Fri, 18 Oct 2024 11:35:11 -0400 Subject: [PATCH] Fixed #1191 Add methods to handle declared type dependencies. --- .../FamixTClass.extension.st | 8 +++++++ .../FamixTMethod.extension.st | 8 +++++++ .../FamixTPackage.extension.st | 7 +++++++ .../FamixTTypedEntity.extension.st | 7 +++++++ ...dencyStructuralMatrixBrowserModel.class.st | 21 ++++++++++++++----- .../TEntityMetaLevelDependency.extension.st | 15 +++++++++++++ 6 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 src/MooseIDE-Dependency/FamixTClass.extension.st create mode 100644 src/MooseIDE-Dependency/FamixTMethod.extension.st create mode 100644 src/MooseIDE-Dependency/FamixTPackage.extension.st create mode 100644 src/MooseIDE-Dependency/FamixTTypedEntity.extension.st diff --git a/src/MooseIDE-Dependency/FamixTClass.extension.st b/src/MooseIDE-Dependency/FamixTClass.extension.st new file mode 100644 index 000000000..5b857cc32 --- /dev/null +++ b/src/MooseIDE-Dependency/FamixTClass.extension.st @@ -0,0 +1,8 @@ +Extension { #name : #FamixTClass } + +{ #category : #'*MooseIDE-Dependency' } +FamixTClass >> addDeclaredTypesIn: dependencies [ + + self children do: [ :c | c addDeclaredTypesIn: dependencies ]. + +] diff --git a/src/MooseIDE-Dependency/FamixTMethod.extension.st b/src/MooseIDE-Dependency/FamixTMethod.extension.st new file mode 100644 index 000000000..25c0bc9cf --- /dev/null +++ b/src/MooseIDE-Dependency/FamixTMethod.extension.st @@ -0,0 +1,8 @@ +Extension { #name : #FamixTMethod } + +{ #category : #'*MooseIDE-Dependency' } +FamixTMethod >> addDeclaredTypesIn: dependencies [ + + self children do: [ :c | c addDeclaredTypesIn: dependencies ]. + self declaredType ifNotNil: [ dependencies add: self declaredType ] +] diff --git a/src/MooseIDE-Dependency/FamixTPackage.extension.st b/src/MooseIDE-Dependency/FamixTPackage.extension.st new file mode 100644 index 000000000..2da7568fc --- /dev/null +++ b/src/MooseIDE-Dependency/FamixTPackage.extension.st @@ -0,0 +1,7 @@ +Extension { #name : #FamixTPackage } + +{ #category : #'*MooseIDE-Dependency' } +FamixTPackage >> addDeclaredTypesIn: dependencies [ + + self children do: [ :c | c addDeclaredTypesIn: dependencies ]. +] diff --git a/src/MooseIDE-Dependency/FamixTTypedEntity.extension.st b/src/MooseIDE-Dependency/FamixTTypedEntity.extension.st new file mode 100644 index 000000000..10625b69a --- /dev/null +++ b/src/MooseIDE-Dependency/FamixTTypedEntity.extension.st @@ -0,0 +1,7 @@ +Extension { #name : #FamixTTypedEntity } + +{ #category : #'*MooseIDE-Dependency' } +FamixTTypedEntity >> addDeclaredTypesIn: dependencies [ + + self declaredType ifNotNil: [dependencies add: self declaredType. "1haltIf: [ dependencies anySatisfy: [:e | e isLocalVariable] ]".] +] diff --git a/src/MooseIDE-Dependency/MiDependencyStructuralMatrixBrowserModel.class.st b/src/MooseIDE-Dependency/MiDependencyStructuralMatrixBrowserModel.class.st index b3641e372..6f21b15e6 100644 --- a/src/MooseIDE-Dependency/MiDependencyStructuralMatrixBrowserModel.class.st +++ b/src/MooseIDE-Dependency/MiDependencyStructuralMatrixBrowserModel.class.st @@ -114,12 +114,23 @@ MiDependencyStructuralMatrixBrowserModel >> getTupleDependencyWeight: tuple [ ^(tuple key = tuple value) ifTrue: [ ^0 ] ifFalse: [ - tuple key model queryAllOutgoing count: [ :dependency || opposites | - opposites := dependency target. - opposites isCollection - ifTrue: [ opposites anySatisfy: [ :each | (each atScope: tuple value model class) includes: tuple value model] ] - ifFalse: [(opposites atScope: tuple value model class) includes: tuple value model ] + tuple key model queryAllOutgoingForDSM count: [ :dependency || opposites | + dependency isAssociation ifTrue: [ + "Association so need to get the target because DSM is done between entities" + opposites := dependency target. + opposites isCollection + ifTrue: [ opposites anySatisfy: [ :each | (each atScope: tuple value model class) includes: tuple value model] ] + "The ifNotNil is to avoid the null dependency problem coming from the model due to generic types" + ifFalse: [ opposites + ifNotNil: [ (opposites atScope: tuple value model class) includes: tuple value model ] + ifNil: [false]] + ] + ifFalse: [ + "Case of declaredType" + dependency isStub ifTrue: [ false ] ifFalse: [ (dependency atScope: tuple value model class) includes: tuple value model ] + ] ] + ] ] diff --git a/src/MooseIDE-Dependency/TEntityMetaLevelDependency.extension.st b/src/MooseIDE-Dependency/TEntityMetaLevelDependency.extension.st index 739200f0b..72356a6f7 100644 --- a/src/MooseIDE-Dependency/TEntityMetaLevelDependency.extension.st +++ b/src/MooseIDE-Dependency/TEntityMetaLevelDependency.extension.st @@ -17,6 +17,21 @@ TEntityMetaLevelDependency >> miTreeExtension [ beResizable ] +{ #category : #'*MooseIDE-Dependency' } +TEntityMetaLevelDependency >> queryAllOutgoingForDSM [ + "Query all the outgoing associations of the receiver and its children. + + Example: + aFAMIXClass queryAllOutgoing. + --> Will return a MooseOutgoingQueryResult containing the FAMIXAssociation having aFAMIXClass or its children as source + " + + | dependencies | + dependencies := self queryAllOutgoing. + self addDeclaredTypesIn: dependencies. + ^ dependencies +] + { #category : #'*MooseIDE-Dependency' } TEntityMetaLevelDependency >> rootsForTreeMap [