[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools.jdt] JDT Builder and AST content
|
Is it expected that, after the JDT builder has been invoked by the
platform on a Java project (because of a change to a java source file),
creating an AST tree may return a tree that does not contain up-to-date
information?
I'm asking this because I found myself in the following situation:
- I have two projects P1 and P2, P2 depends on P1
- Class B (in P2) is using (invoking) method A.foo() (in P1)
- I refactor the signature of A.foo(), adding an additional parameter of
type Object, with default value null.
- The builder I have defined in project P2 (which is invoked
sequentially after the JDT builder), is invoked because the source file
of B has changed (invocation of A.foo() changed to A.foo(null))
- My builder performs the following:
ICompilationUnit compilationUnitOfB;
ASTParser parser = ASTParser.newParser(AST.JLS2);
parser.setSource(compilationUnitOfB);
parser.setResolveBindings(true);
CompilationUnit ASTNode = (CompilationUnit)parser.createAST(null);
IProblem[] problems=ASTNode.getProblems();
- problems contains the following error:
Pb(115) The method foo() in the type A is not applicable for the
arguments (null)
- If a I invoke the same code above after sleeping for 2 seconds, no
problems are reported.
So, it looks like the AST tree (or something it depends on) is updated
asynchronously after the JDT builder has been invoked. Is there a way to
make sure that the AST node I am requesting is up-to-date with regards
to the source file?
Thanks,
Julien