From 3b709fcd2e9c8ac19ce1bf5622c15393609c6bac Mon Sep 17 00:00:00 2001 From: anquetil Date: Sun, 17 Nov 2024 14:10:12 +0100 Subject: [PATCH] 2 more tests --- .../FamixTMethod.extension.st | 14 ++++++++- ...ndencyStructuralMatrixBrowserTest.class.st | 29 ++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/MooseIDE-Dependency/FamixTMethod.extension.st b/src/MooseIDE-Dependency/FamixTMethod.extension.st index f1668757..407e1639 100644 --- a/src/MooseIDE-Dependency/FamixTMethod.extension.st +++ b/src/MooseIDE-Dependency/FamixTMethod.extension.st @@ -4,5 +4,17 @@ Extension { #name : #FamixTMethod } FamixTMethod >> addNonAssociationDependenciesTo: dependencies [ self children do: [ :c | c addNonAssociationDependenciesTo: dependencies ]. - self declaredType ifNotNil: [ dependencies add: self declaredType ] + + declaredType ifNotNil: [ + dependencies add: declaredType. + + ( (declaredType usesFamixTrait: FamixTParametricEntity) and: + [ declaredType genericization isNotNil ]) + ifTrue: [ + declaredType concreteParameters do: [ :param | + param children ifNotEmpty: [ dependencies add: param ] + ] + ] + + ] ] diff --git a/src/MooseIDE-Tests/MiDependencyStructuralMatrixBrowserTest.class.st b/src/MooseIDE-Tests/MiDependencyStructuralMatrixBrowserTest.class.st index 646ef84b..39e16575 100644 --- a/src/MooseIDE-Tests/MiDependencyStructuralMatrixBrowserTest.class.st +++ b/src/MooseIDE-Tests/MiDependencyStructuralMatrixBrowserTest.class.st @@ -139,6 +139,33 @@ MiDependencyStructuralMatrixBrowserTest >> testOutgoingDependencyFromMethodDecla ] +{ #category : #tests } +MiDependencyStructuralMatrixBrowserTest >> testOutgoingDependencyFromVMethodDeclaredTypeParametric [ + "code: + Class2 + ParametricClass mth2 + Note: FamixJavaConcretization is an association and we are not interested in its genericEntity here + Note: hueristic to detect a concreteParameter being a genuine class is to check it has children + That's why we use Class1 and not Class3 as concreteParameter" + + | mth2 parametricClass dependencies | + parametricClass := model newParametricClass + name: 'ParametricClass' ; + genericization: model newConcretization ; + addConcreteParameter: class1 ; + yourself. + + mth2 := class2 methods anyOne. + mth2 declaredType: parametricClass. + + dependencies := mth2 queryAllOutgoingForDSM. + + self assert: dependencies size equals: 2. + dependencies do: [ :dep | + { 'ParametricClass' . 'Class1' } includes: dep name + ] +] + { #category : #tests } MiDependencyStructuralMatrixBrowserTest >> testOutgoingDependencyFromVariableDeclaredType [ @@ -161,7 +188,7 @@ MiDependencyStructuralMatrixBrowserTest >> testOutgoingDependencyFromVariableDec "code: Class2 mth2 - ParametricClass local2 + ParametricClass local2 Note: FamixJavaConcretization is an association and we are not interested in its genericEntity here Note: hueristic to detect a concreteParameter being a genuine class is to check it has children That's why we use Class1 and not Class3 as concreteParameter"