Community
Participate
Working Groups
This problem is accurately described on this forum post. Please see http://www.eclipse.org/forums/index.php?t=msg&th=198618&start=0&S=f0b48be00b6c5feb6c55ad616fb63f2f Basically the issue is that the parse tree model doesn't seem to be updating line number properly when the file is being edited/saved. For example, say you have a DSL like this: 1. state A { 2. do1(); 3. do2(); 4. } 5. 6. state B { 7. do3(); 8. do4(); 9. } If I write the following code: MyDSL model = (MyDSL) resource.getContents().get(0); EList<State> states = model.getStates(); for (State s : states) System.out.println(s.getName() + " " + NodeUtil.getAdapter(s).getParserNode().getLine(); I should get this: A 1 B 6 This works fine and is correct. However, now if I edit the file so it looks like this: 1. state A { 2. do1(); 3. do2(); 4. do5(); 5. } 6. 7. state B { 8. do3(); 9. do4(); 10. } I save the file and run the above code, I get A 1 B 6 The line numbers are now wrong. Should be 1 and 7 for A,B, respectively. Now say, I delete line 6 (empty line), reinserted it, saved the file, and ran the code. In that case, the line numbers would be correct and I get 1,7. Basically, whenever I'm editing inside the state {} block the line numbers don't seem to be getting updated and are stale. Hope this can be fixed soon and a release/patch made available. Thanks.
Should be fixed with the new node model implementation.
I cannot reproduce this in Xtext 1.0.1. Could you provide a sample grammar and a test case? Please also make sure not to refer to a stale object: Check if the element with the wrong line information has eResource() != null. Are you using cross-resource containment?
setting this to fixed see comment #2 and #3
Closing all bugs that were set to RESOLVED before Neon.0