Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 329624

Summary: Partial parser doesn't replace empty nodes with error markers
Product: [Modeling] TMF Reporter: Ralf Ebert <ralf>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: sebastian.zarnekow, sven.efftinge
Version: 1.0.1Flags: sebastian.zarnekow: indigo+
Target Milestone: M7   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
0001-added-IndentationAwareTestLanguage.patch
none
0002-generated-IndentationAwareTestLanguage.patch
none
0003-added-PartialParsingEmptyTokensTest.patch
none
0004-Range-encloses-getLength-extracted-from-PartialParsi.patch
none
0005-Parse-tree-helper-methods-for-partial-parsing-in-Nod.patch
none
0006-Fixed-PartialParsingEmptyTokensTest.patch none

Description Ralf Ebert CLA 2010-11-06 19:13:55 EDT
PartialParsingHelper#calculatePartialParsingPointers currently merges all document errors in the replace region and looks for a node that encloses this region. Merging error nodes fails if the error is sitting on a document node that is empty (totalLength = 0), because it cannot grasp this node using an offset + length.

This can happen with an AbstractSplittingTokenSource that inserts synthetic tokens in the token stream to represent concepts that don't have a direct representation in the text document, f.e. BEGIN/END tokens for increasing/decreasing indentation in the document.

Attached patch series fixes this issue regarding partial parsing and such synthetic tokens.

0001/0002 adds a simple indentation-sensitive test-language. It doesn't work yet with partial parsing as IndentTokenSource is stateful. Still, it is useful to demonstrate this issue and as I plan to continue the work on such languages, it would be great if this could sit around as general-purpose test language so I could refer to it in later patches.

0003 adds a test that shows the problem regarding partial parsing and empty tokens (thx again to Jan who helped me to get this working at ESE)

0004+0005 extracts some general-purpose code from PartialParsingHelper into the general-purpose Range / NodeUtil classes. I added functionality to walk trees searching for specific nodes matching a predicate and narrow it up to enclose a document region. Includes docs + tests.

0006 uses this new functionality to find the node(s) that encloses the document region and includes all errors. Essentially, this changes the inclusion of errors 'by document region' to 'by node'.

AllTests are green for me.
Comment 1 Ralf Ebert CLA 2010-11-06 19:14:42 EDT
Created attachment 182561 [details]
0001-added-IndentationAwareTestLanguage.patch
Comment 2 Ralf Ebert CLA 2010-11-06 19:14:58 EDT
Created attachment 182562 [details]
0002-generated-IndentationAwareTestLanguage.patch
Comment 3 Ralf Ebert CLA 2010-11-06 19:15:11 EDT
Created attachment 182563 [details]
0003-added-PartialParsingEmptyTokensTest.patch
Comment 4 Ralf Ebert CLA 2010-11-06 19:15:32 EDT
Created attachment 182564 [details]
0004-Range-encloses-getLength-extracted-from-PartialParsi.patch
Comment 5 Ralf Ebert CLA 2010-11-06 19:15:44 EDT
Created attachment 182565 [details]
0005-Parse-tree-helper-methods-for-partial-parsing-in-Nod.patch
Comment 6 Ralf Ebert CLA 2010-11-06 19:15:55 EDT
Created attachment 182566 [details]
0006-Fixed-PartialParsingEmptyTokensTest.patch
Comment 7 Sebastian Zarnekow CLA 2011-03-28 09:11:29 EDT
The attached testcase did not fail with the given sample language. I pushed the test to the repo. Please reopen with a new test attached if the problem is still present.
Comment 8 Sebastian Zarnekow CLA 2011-03-28 09:12:02 EDT
Tested with the 2.0 stream.
Comment 9 Karsten Thoms CLA 2017-09-19 17:33:04 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 10 Karsten Thoms CLA 2017-09-19 17:44:16 EDT
Closing all bugs that were set to RESOLVED before Neon.0