Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 345874 - [nodemodel] NPE when calling NodeModelUtils.findLeafNodeAtOffset() for RootNode of empty document
Summary: [nodemodel] NPE when calling NodeModelUtils.findLeafNodeAtOffset() for RootNo...
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: Final   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-16 02:19 EDT by Knut Wannheden CLA
Modified: 2017-09-19 18:01 EDT (History)
1 user (show)

See Also:
sebastian.zarnekow: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Knut Wannheden CLA 2011-05-16 02:19:29 EDT
I have a ISelectionChangedListener attached to my XtextSourceViewer which when called, calls (within a readonly transaction) NodeModelUtils#findLeafNodeAtOffset() with XtextResource.getParseResult().getRootNode() as the first argument and the selection offset obtained from the SelectionChangedEvent as the second argument.

If the Xtext document is emtpy (i.e. length == 0) I get the following NPE when calling NodeModelUtils#findLeafNodeAtOffset():


java.lang.NullPointerException
	at org.eclipse.xtext.nodemodel.impl.BasicNodeTreeIterator.hasNext(BasicNodeTreeIterator.java:45)
	at org.eclipse.xtext.nodemodel.util.NodeModelUtils.findLeafNodeAtOffset(NodeModelUtils.java:67)

That is because basicGetParent() returned null for the RootNode.
Comment 1 Sebastian Zarnekow CLA 2011-05-30 03:17:16 EDT
Marked as critical since the (Basic)TreeNodeIterator is used at other places, too.
Comment 2 Sebastian Zarnekow CLA 2011-06-03 01:56:29 EDT
Postponed since there are valid workarounds.
Comment 3 Sebastian Zarnekow CLA 2011-07-29 18:02:48 EDT
This one was already resolved with commit a40e333e7c964a391c4179c36afe11011104a3ea

I could reproduce it with the previous version of the iterator but the tests are green for the released version.
Comment 4 Karsten Thoms CLA 2017-09-19 17:50:32 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 5 Karsten Thoms CLA 2017-09-19 18:01:23 EDT
Closing all bugs that were set to RESOLVED before Neon.0