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

Bug 349626

Summary: NullPointerException in EObjectAtOffsetHelper
Product: [Modeling] TMF Reporter: Michael Clay <clay>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: kimi_anwen, knut.wannheden, stephan.herrmann, sven.efftinge
Version: 2.0.0Flags: sven.efftinge: indigo+
Target Milestone: SR2   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Bug Depends on: 347284    
Bug Blocks:    

Description Michael Clay CLA 2011-06-16 16:22:47 EDT
steps to reproduce:

1. open editor
2. enable mark occurences
3. select/position behind last element

java.lang.NullPointerException
	at org.eclipse.xtext.resource.EObjectAtOffsetHelper.internalResolveElementAt(EObjectAtOffsetHelper.java:42)
	at org.eclipse.xtext.resource.EObjectAtOffsetHelper.resolveElementAt(EObjectAtOffsetHelper.java:31)
	at org.eclipse.xtext.ui.editor.occurrences.DefaultOccurrenceComputer$1.exec(DefaultOccurrenceComputer.java:84)
	at org.eclipse.xtext.ui.editor.occurrences.DefaultOccurrenceComputer$1.exec(DefaultOccurrenceComputer.java:1)
	at org.eclipse.xtext.util.concurrent.AbstractReadWriteAcces.readOnly(AbstractReadWriteAcces.java:32)
	at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:86)
	at org.eclipse.xtext.ui.editor.occurrences.DefaultOccurrenceComputer.createAnnotationMap(DefaultOccurrenceComputer.java:82)
	at org.eclipse.xtext.ui.editor.occurrences.OccurrenceMarker$MarkOccurrenceJob.run(OccurrenceMarker.java:119)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Comment 1 Michael Clay CLA 2011-06-16 16:54:43 EDT
added missing null guard and test -> pushed to master
Comment 2 Knut Wannheden CLA 2011-06-17 01:39:02 EDT
Shouldn't the EObjectAtOffsetHelper instead of returning null try to resolve the previous token if the offset is at the end of the document? This is of course also related to bug 347284.
Comment 3 Michael Clay CLA 2011-06-17 07:52:52 EDT
tbd see bug 347284
Comment 4 Michael Clay CLA 2011-06-29 12:51:09 EDT
*** Bug 350708 has been marked as a duplicate of this bug. ***
Comment 5 Timotei D CLA 2011-07-30 13:41:01 EDT
I have the same problem. I use the method in my character pair matcher, and using the EObjectAtOffsetHelper.resolveElementAt() method.

However, when clicking at the end of the file and got errors syntax , and I get the NPE at the same stack trace.
Comment 6 Stephan Herrmann CLA 2011-08-14 09:50:52 EDT
Target Milestone = SR2? 
This would mean that for DSLs affected by this bug mark occurrences
should be turned off until next year?
That'd be a pity.
Comment 7 Sven Efftinge CLA 2011-08-15 02:41:55 EDT
SR2 is the flag we use for the 2.1 release which is planned for mid October.
Comment 8 Stephan Herrmann CLA 2011-08-15 11:20:46 EDT
(In reply to comment #7)
> SR2 is the flag we use for the 2.1 release which is planned for mid October.

ups, seems I misinterpreted SR1 to mean Indigo SR1 :)

Thanks for clarification, that's good news actually!
Comment 9 Sven Efftinge CLA 2011-08-24 04:25:39 EDT
Closing this since the NPW has been handled and the outstanding issue is covered in Bug #347284