I am traversing an AST using a JDT ASTVisitor.
private void removeOverrideAnnotations(CompilationUnit astUnit) {
astUnit.accept(new ASTVisitor() {
@Override
public boolean visit(MethodDeclaration methodDeclarationNode) {
if (isOverridingMethodOfSuperclass(methodDeclarationNode)) {
... process ...
}
return super.visit(methodDeclarationNode);
}
});
}
How can I find out if the MethodDeclaration I am visiting is overriding a superclass method?
Refer the below link for an overrride method search. Basically it does an exhaustive search on the project, finds the superclasses of a Type and checks each method with superclass method for the same name and arguments.