Community
Participate
Working Groups
Using build I200208270833 Running this code IWorkspace ws = testcasesPlugin.getWorkspace(); IWorkspaceRoot root = ws.getRoot(); IProject project = root.getProjects()[0]; IJavaProject jp = JavaCore.create(project); CompilationUnit cu = AST.parseCompilationUnit( "public class Class {void theMethod() {for (int i = 0; i < 5; ++i); theMethod ();}}".toCharArray(), "Class", jp); cu.accept(new ASTVisitor() { public boolean visit(SimpleName node) { IBinding binding = node.resolveBinding(); if (null == binding) { System.out.println("Null binding for SimpleName " + node.getIdentifier ()); } return true; } }); produces the output Null binding for SimpleName i Null binding for SimpleName theMethod The null binding for 'i' is, I assume, bug 11529. The null binding for the invocation of theMethod is caused by the call to ForStatement.getBody() in ForStatement.accept0(). This calls ForStatement.setBody() because the for statement had an empty body. The call to setBody changes the modification count on the AST which causes all further attempts at binding resolution to return null. I think the lazy initialization has to go :-) Similarly for other loops. Thanks Mark
The body of the forStatement should be set during the conversion. I will investigate.
This is an issue related to the empty statement. I am looking into it. Other statements are broken and I'd like to fix all of them at the same time.
Fixed and released in 2.1 stream.
Verified.
Regression tests added (test0371, test0372)