Skip to content

Commit

Permalink
Merge pull request #830 from moosetechnology/828-overridingMethods-on…
Browse files Browse the repository at this point in the history
…-methods-from-FamixJavaEnum-does-not-work

Fix #828: Add `overridingMethods` on FamixJavaEnum
  • Loading branch information
Gabriel-Darbord authored Sep 27, 2024
2 parents 202f56b + dbba092 commit 94c6188
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/Famix-Java-Entities/FamixJavaEnum.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions src/Famix-Java-Tests/FamixJavaEnumTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
4 changes: 2 additions & 2 deletions src/Famix-Traits/FamixTClass.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit 94c6188

Please sign in to comment.