Skip to content

Commit

Permalink
feature: CtMethod#isOverriding(CtMethod)
Browse files Browse the repository at this point in the history
  • Loading branch information
pvojtechovsky committed Apr 30, 2017
1 parent f993132 commit f8ba46e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/spoon/reflect/declaration/CtMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
* This element defines a method declaration.
*/
public interface CtMethod<T> extends CtExecutable<T>, CtTypeMember, CtFormalTypeDeclarer, CtShadowable {
/**
* @param superMethod to be checked method
* @return true if this method overrides `superMethod`
*/
boolean isOverriding(CtMethod<?> superMethod);
/**
* Checks if the method is a default method. Default method can be in interfaces from
* Java 8: http://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import spoon.reflect.declaration.ModifierKind;
import spoon.reflect.reference.CtTypeReference;
import spoon.reflect.visitor.CtVisitor;
import spoon.support.visitor.MethodTypingContext;

import java.util.ArrayList;
import java.util.EnumSet;
Expand Down Expand Up @@ -186,6 +187,11 @@ public <R extends T> void replace(CtMethod<T> element) {
replace((CtElement) element);
}

@Override
public boolean isOverriding(CtMethod<?> superMethod) {
return new MethodTypingContext().setMethod(this).isOverriding(superMethod);
}

boolean isShadow;

@Override
Expand Down

0 comments on commit f8ba46e

Please sign in to comment.