[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [cdt-dev] inconsistent ASTNodeLocations vs SourceCodeEditor
|
The AST represents a snapshot of your source-code and will
not change afterwards. If you need an AST for the modified code, you need to
recreate it.
If you just need to convert positions, you can use
CCorePlugin.getPositionTrackerManager().
Markus.
hi (again)
I have an AST from a workingCopy and would like
to go to the FileLocation of certain nodes in it, but as one writes in the
editor the ASTNodes locations does not change accordingly to the changes of
the editor.
How do I get the ASTNodes to update their locations as the
editor changes?
IWorkingCopy iWorkingCopy =
CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
ICElement
element = iWorkingCopy;
if (element instanceof ITranslationUnit)
{
tu = ((ITranslationUnit)element);
...
then
on some node in the AST
iASTNode.getFileLocation(); // will reference the
location it was when it first got the AST, its not updating its location as
the workingCopy changes
Anyone who can tell how to get
the AST updated...
I tried
iWorkingCopy.reconcil(); // all
overloaded versions of this one...
iWorkingCopy.commit(force,
monitor);
tu.makeConsistent(); // all overloaded versions of this
one...
Do I need to listen to the editors changes manually and then
update all nodes when I need to go to their location? or even worse, parse the
workingCopy from start to get it updated?
I hate tial&error
programming... any pointers is greatly
appreciated
/Jimmie