Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Retrieve file location of new nodes in AST

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,
-- Tomasz Wesołowski


Back to the top