Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 344399 - NodeModelUtils.compactDump causes NPE when there are parse errors
Summary: NodeModelUtils.compactDump causes NPE when there are parse errors
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 0.8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: SR1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-01 09:45 EDT by Henrik Lindberg CLA
Modified: 2017-09-19 17:45 EDT (History)
1 user (show)

See Also:
moritz.eysholdt: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Henrik Lindberg CLA 2011-05-01 09:45:16 EDT
It would be very useful to dump a parsed tree when there are syntax errors (do debug what the parser actually did parse). This fails with an NPE with the stack trace of:

java.lang.NullPointerException
	at org.eclipse.xtext.util.XtextSwitch.doSwitch(XtextSwitch.java:58)
	at org.eclipse.xtext.nodemodel.util.NodeModelUtils.compactDump(NodeModelUtils.java:281)
	at org.eclipse.xtext.nodemodel.util.NodeModelUtils.compactDump(NodeModelUtils.java:273)
	at org.eclipse.xtext.nodemodel.util.NodeModelUtils.compactDump(NodeModelUtils.java:273)

(at the top).
This is caused by node.getGrammarElement() being passed to XtextSwitch. There should be a guard there that produces a label like "error".
Comment 1 Moritz Eysholdt CLA 2011-07-11 04:39:56 EDT
this is indeed annoying.
Comment 2 Moritz Eysholdt CLA 2011-07-12 08:31:12 EDT
fixed in master. changes:
- check if node.getGrammarElement() is null to avoid NPEs.
- include syntax error messages into the dump if they exist.
Comment 3 Karsten Thoms CLA 2017-09-19 17:34:50 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 4 Karsten Thoms CLA 2017-09-19 17:45:58 EDT
Closing all bugs that were set to RESOLVED before Neon.0