diff --git a/src/Famix-Java-Entities/FamixJavaEnum.class.st b/src/Famix-Java-Entities/FamixJavaEnum.class.st index 518ae1cf..623c1a6e 100644 --- a/src/Famix-Java-Entities/FamixJavaEnum.class.st +++ b/src/Famix-Java-Entities/FamixJavaEnum.class.st @@ -62,6 +62,16 @@ FamixJavaEnum class >> annotation [ ^ self ] +{ #category : #private } +FamixJavaEnum >> addMethodOverriding: aMethod in: aCollection [ + + self directSubclasses do: [ :subClass | + subClass methods + detect: [ :method | method signature = aMethod signature ] + ifFound: [ :overridingMethod | aCollection add: overridingMethod ]. + subClass addMethodOverriding: aMethod in: aCollection ] +] + { #category : #accessing } FamixJavaEnum >> values [ ^ self enumValues diff --git a/src/Famix-Java-Tests/FamixJavaEnumTest.class.st b/src/Famix-Java-Tests/FamixJavaEnumTest.class.st index e726aeb8..8f3d7600 100644 --- a/src/Famix-Java-Tests/FamixJavaEnumTest.class.st +++ b/src/Famix-Java-Tests/FamixJavaEnumTest.class.st @@ -4,6 +4,30 @@ Class { #category : #'Famix-Java-Tests' } +{ #category : #tests } +FamixJavaEnumTest >> testOverridingMethods [ + + | method signature overridingMethod c1 c2 | + method := FamixJavaMethod new. + signature := 'javaMethod()'. + method signature: signature. + overridingMethod := FamixJavaMethod new signature: signature. + + c1 := FamixJavaEnum new. + c2 := FamixJavaEnum new. + + c1 addMethod: method. + c2 addMethod: overridingMethod. + + FamixJavaInheritance new + superclass: c1; + subclass: c2. + + self + assertCollection: method overridingMethods + hasSameElements: { overridingMethod } +] + { #category : #tests } FamixJavaEnumTest >> testValues [ | enum value | diff --git a/src/Famix-Traits/FamixTClass.trait.st b/src/Famix-Traits/FamixTClass.trait.st index 70704a9a..78449e92 100644 --- a/src/Famix-Traits/FamixTClass.trait.st +++ b/src/Famix-Traits/FamixTClass.trait.st @@ -86,9 +86,9 @@ FamixTClass >> addMethodOverriding: aMethod in: aCollection [ self directSubclasses do: [ :subClass | subClass methods - detect: [ :method | method signature = aMethod signature ] + detect: [ :method | method signature = aMethod signature ] ifFound: [ :overridingMethod | aCollection add: overridingMethod ]. - subClass addMethodOverriding: aMethod in: aCollection ] + subClass addMethodOverriding: aMethod in: aCollection ] ] { #category : #metrics }