I'm looking for a way to find the IMethod, given the method name as input for developing my eclipse plugin further.
Couldn't figure out a way to do so.
can someone please direct me in the right path.
There can be two approaches:
You can use the ASTVisitor
pattern to visit the MethodDeclaration
nodes, do a check for name and arguments, and get IMethod
from them by resolving the binding. Refer the below posts:
Get the IType
s from the compilation unit and loop through the IMethods
, do check for name and arguments to find the required one.
IType [] typeDeclarationList = unit.getTypes();
for (IType typeDeclaration : typeDeclarationList) {
// Get methods under each type declaration.
IMethod [] methodList = typeDeclaration.getMethods();
for (IMethod method : methodList) {
// Logic here.
}
}