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

Bug 344399

Summary: NodeModelUtils.compactDump causes NPE when there are parse errors
Product: [Modeling] TMF Reporter: Henrik Lindberg <henrik.lindberg>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: moritz.eysholdt
Version: 0.8.0Flags: moritz.eysholdt: indigo+
Target Milestone: SR1   
Hardware: All   
OS: All   
Whiteboard:

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