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

Bug 361609

Summary: Unhelpful pop-ups for quickfix failures
Product: [Modeling] TMF Reporter: Ed Willink <ed>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: sebastian.zarnekow
Version: 2.0.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Whiteboard:

Description Ed Willink CLA 2011-10-21 03:00:22 EDT
e4.2M2: My quick fix probably has a fault and so a hover has an NPE.

This results in a simple popup, just reporting "Internal Error" and Null Pointer Exception. No clue as to the application or context. The error log is more informative.

Suggest: no pop-up for quick fix failures, or full details in pop-up.

java.lang.NullPointerException
	at org.eclipse.emf.common.util.URI.createURIWithCache(URI.java:669)
	at org.eclipse.emf.common.util.URI.createURI(URI.java:541)
	at org.eclipse.ocl.examples.xtext.base.scoping.cs.RootPackageCSScopeAdapter.computeLookup(RootPackageCSScopeAdapter.java:67)
	at org.eclipse.ocl.examples.xtext.base.scope.BaseScopeView.computeLookupWithParents(BaseScopeView.java:78)
	at org.eclipse.ocl.examples.xtext.base.scope.BaseScopeView.computeLookupWithParents(BaseScopeView.java:81)
	at org.eclipse.ocl.examples.xtext.base.scope.BaseScopeView.computeLookupWithParents(BaseScopeView.java:81)
	at org.eclipse.ocl.examples.xtext.base.scope.BaseScopeView.computeLookupWithParents(BaseScopeView.java:81)
	at org.eclipse.ocl.examples.xtext.base.scope.BaseScopeView.computeLookupWithParents(BaseScopeView.java:81)
	at org.eclipse.ocl.examples.xtext.base.scope.BaseScopeView.computeLookupWithParents(BaseScopeView.java:81)
	at org.eclipse.ocl.examples.xtext.base.scope.BaseScopeView.computeLookupWithParents(BaseScopeView.java:81)
	at org.eclipse.ocl.examples.xtext.base.scope.BaseScopeView.computeLookupWithParents(BaseScopeView.java:81)
	at org.eclipse.ocl.examples.xtext.base.scope.BaseScopeView.getAllElements(BaseScopeView.java:90)
	at org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider.queryScope(DefaultQuickfixProvider.java:130)
	at org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider$1.process(DefaultQuickfixProvider.java:98)
	at org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider$1.process(DefaultQuickfixProvider.java:1)
	at org.eclipse.xtext.util.concurrent.IUnitOfWork$Void.exec(IUnitOfWork.java:36)
	at org.eclipse.xtext.util.concurrent.AbstractReadWriteAcces.readOnly(AbstractReadWriteAcces.java:32)
	at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:78)
	at org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider.createLinkingIssueResolutions(DefaultQuickfixProvider.java:84)
	at org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider.getResolutionsForLinkingIssue(DefaultQuickfixProvider.java:77)
	at org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider.getResolutions(DefaultQuickfixProvider.java:160)
	at org.eclipse.xtext.ui.editor.quickfix.AbstractIssueResolutionProviderAdapter.getResolutions(AbstractIssueResolutionProviderAdapter.java:42)
	at org.eclipse.xtext.ui.editor.quickfix.XtextQuickAssistProcessor.computeQuickAssistProposals(XtextQuickAssistProcessor.java:89)
	at org.eclipse.xtext.ui.editor.hover.AnnotationWithQuickFixesHover$CompletionProposalRunnable.run(AnnotationWithQuickFixesHover.java:592)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:180)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:150)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:4683)
	at org.eclipse.xtext.ui.editor.hover.AnnotationWithQuickFixesHover.getHoverInfoInternal(AnnotationWithQuickFixesHover.java:692)
	at org.eclipse.xtext.ui.editor.hover.AbstractProblemHover.getHoverInfo2(AbstractProblemHover.java:55)
	at org.eclipse.xtext.ui.editor.hover.AbstractCompositeHover.getHoverRegion(AbstractCompositeHover.java:67)
	at org.eclipse.jface.text.TextViewerHoverManager.computeInformation(TextViewerHoverManager.java:140)
	at org.eclipse.jface.text.AbstractInformationControlManager.doShowInformation(AbstractInformationControlManager.java:1131)
	at org.eclipse.jface.text.AbstractHoverInformationControlManager$MouseTracker.mouseHover(AbstractHoverInformationControlManager.java:519)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:207)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
Comment 1 Sebastian Zarnekow CLA 2012-04-03 12:35:49 EDT
Could you please elaborate why the NPE in RootPackageCSScopeAdapter.computeLookup is a bug in the Xtext hover implementation? What would you expect to happen? No popup?
Comment 2 Ed Willink CLA 2012-04-03 12:51:21 EDT
(In reply to comment #1)
> Could you please elaborate why the NPE in
> RootPackageCSScopeAdapter.computeLookup is a bug in the Xtext hover
> implementation? What would you expect to happen? No popup?

The NPE in my code is clearly my bug, but it is an example of bad user code that the Xtext framework could handle more gracefully.

I suggested either
- eliminate the popup when errors occur during Quickfix option listing
- a details button in the popup so that the stack trace can be examined

Another option, catch the exception and offer a quickfix such as
<error icon> Unrecognisable quickfix - Details
with Details an underlined hyperlink to the stack trace.