[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [cdt-dev] Retrieve file location of new nodes in AST
|
You cannot have file locations for ASTNodes that are not
created by the parser. If you need information
about ast-nodes that you have created yourself you need to
store it elsewhere.
Furthermore, applying the change does not change the
original AST at all. The rewrite is performed directly
on the source code.
Markus.
Hello,
I have noticed that I cannot retrieve the file
location of an AST node which had been just created.
Let me
illustrate:
ASTRewrite
r = ASTRewrite.create(ast);
/* ... */
r.insertBefore(nearStatement.getParent(),
nearStatement, newStatement, null);
Change c =
r.rewriteAST();
c.perform(new
NullProgressMonitor());
IASTFileLocation location =
newStatement.getFileLocation();
// location is
null
The file location needed to create a LinkedPosition on the
newly created node.
Any solution for that issue? Should I trigger the
recalculation of node positions manually somehow after perform()?
Best
regards,