Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 329624 - Partial parser doesn't replace empty nodes with error markers
Summary: Partial parser doesn't replace empty nodes with error markers
Status: CLOSED WORKSFORME
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 1.0.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: M7   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-06 19:13 EDT by Ralf Ebert CLA
Modified: 2017-09-19 17:44 EDT (History)
2 users (show)

See Also:
sebastian.zarnekow: indigo+


Attachments
0001-added-IndentationAwareTestLanguage.patch (9.78 KB, patch)
2010-11-06 19:14 EDT, Ralf Ebert CLA
no flags Details | Diff
0002-generated-IndentationAwareTestLanguage.patch (138.00 KB, patch)
2010-11-06 19:14 EDT, Ralf Ebert CLA
no flags Details | Diff
0003-added-PartialParsingEmptyTokensTest.patch (2.84 KB, patch)
2010-11-06 19:15 EDT, Ralf Ebert CLA
no flags Details | Diff
0004-Range-encloses-getLength-extracted-from-PartialParsi.patch (7.58 KB, patch)
2010-11-06 19:15 EDT, Ralf Ebert CLA
no flags Details | Diff
0005-Parse-tree-helper-methods-for-partial-parsing-in-Nod.patch (14.16 KB, patch)
2010-11-06 19:15 EDT, Ralf Ebert CLA
no flags Details | Diff
0006-Fixed-PartialParsingEmptyTokensTest.patch (5.94 KB, patch)
2010-11-06 19:15 EDT, Ralf Ebert CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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