假设我有 Hello 类,它有 hello 方法。
public class Hello {
public int hello(int x, int y)
我需要获取“hello”方法的 IMethod 引用。这是我可以获得 IType (Hello) 的代码。
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
// 1. The name of the project in the workspace
IProject project = root.getProject("Hello");
project.open(null /* IProgressMonitor */);
IJavaProject javaProject = JavaCore.create(project);
// 2. The name of the Type (including the namespace)
IType itype = javaProject.findType("smcho.HelloRenameMethod");
IMethod method = itype.findMethod() // ???
我搜索了 IType#findMethod(),但该方法的输入参数是 IMethod 实例,而不是字符串。
如何使用方法名称从 IType 获取 IMethod?或者,我如何使用IType#findMethod()
来获取 IMethod?