Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #828: Add overridingMethods on FamixJavaEnum #830

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading