此方法可以获取项目方法的名称和行的方法数量 ,但似乎没有获取声明这些方法的类。 我已经试过这个帖子 - How to get a class name of a method by using Eclipse JDT ASTParser?,但是当我使用resolveMethodBinding时,它返回null。 public static void calculateAndSaveNumberMe
例如,我从ASTParser获得一个CompilationUnit。为什么我需要接受的,而不是使用正常方法访问者: ASTParser parser ... //all that stuff
CompilationUnit unit = (CompilationUnit) parser.createAST(null);
然后我做的: unit.types() //get all type
我有这样的方法: public static int calc(int a, int b) {
if (a >= b)
return a - b;
return 0;
}
我想知道这是一个已知的行号使用的条件。在这种情况下,我的预期结果是条件的名称,如“> =”。 我知道如何解析给定的ICompilationUnit的CompilationUnit。但是
我这里有一个代码: public class TestOverride {
int foo() {
return -1;
}
}
class B extends TestOverride {
@Override
int foo() {
// error - quick fix to add "return super.foo()
我怎样才能得到org.eclipse.jdt.core.dom.Statement在给定的行号? 假设我有这个类: 1 package foo;
2 public class Operations {
3 public static int calc(int a, int b) {
4 if (a >= b)
5 return a - b;
6 if (a<b || b==2)