Community
Participate
Working Groups
Build Identifier: I20110519-1138 An NPE is thrown when a grammar is opened that is not as a file in the workspace. java.lang.NullPointerException at org.eclipse.xtext.ui.editor.validation.AnnotationIssueProcessor.updateMarkerAnnotations(AnnotationIssueProcessor.java:170) at org.eclipse.xtext.ui.editor.validation.AnnotationIssueProcessor.processIssues(AnnotationIssueProcessor.java:72) at org.eclipse.xtext.ui.editor.validation.ValidationJob.run(ValidationJob.java:67) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) Reproducible: Always Steps to Reproduce: 1. Create a new grammar derived from xbase 2. open the base grammar with CTRL + click on xbase 3. Execute a clean build
Cannot reproduce this. Please reopen if this bug reappears.
Hi Jan, I reopened because I can reproduce this issue on different machines. Maybe this is a platform dependend problem, do you need log files or something? Greets, Andreas
Yes, a log would be helpful, even though this beging to appear a race condition thing. I tried with both, a new project and the domainmodel example on a Mac and everything worked fine. But I remember having seen a similar exception before. Maybe we should just add a NPE guard for a missing annotationModel.
If you add a breakpoint in org.eclipse.xtext.ui.editor.validation.AnnotationIssueProcessor.modelChanged(IAnnotationModel) is the passed in model = null or is it the same as the field annotationModel??
Since #getAnnotationsToRemove has this guard if (monitor.isCanceled() || annotationModel == null) { return Lists.newArrayList(); } I'd assume that the annotation model may be null. We should probably move the guard to #processIssues ?
If a grammar file outside the workspace is opened, XtextReadonlyEditorInput is used. This implements IStorageEditorInput instead of IFileEditorInput. Thus, the StorageDocumentProvider is used instead of the FileDocumentProvider and StorageDocumentProvider#createAnnotationModel simply returns null. Thus, null is passed to the constructor of the AnnotationIssueProcessor. I don't know whats the best solution - let XtextReadonlyEditorInput implement IFileEditorInput or add some null checks in the AnnotationIssueProcessor?
FInally I could reproduce it: It does not occur if you open a file from the original workspace from a runtime Eclipse, as the folders are linked such that IFiles can be used... To run validation on an editor without an annotation model doesn't make sense, neither does an AnnotationIssueProcessor without annotation model. I added a guard in the XtextDocumentProvider and explicitly throw an exception when someone tries to instantiate an AIP without annotation model. Pushed to MASTER.
*** Bug 349990 has been marked as a duplicate of this bug. ***
Closing all bugs that were set to RESOLVED before Neon.0