Best Solution for when ISemanticModification quickfix results in an InvalidConcreteSyntaxException [message #1735647] |
Tue, 21 June 2016 11:02  |
Eclipse User |
|
|
|
Using Xtext's DefaultQuickfixProvider we have created an ISemanticModification quickfix for a validator.
In case a model contains a parse error, execution of the quickfix results in an InvalidConcreteSyntaxException, because the model can not be serialized (after the modification).
However, the parse error is not in the semantic object itself, but in the parent container eobject (in the textual representation just after the modification).
We are thinking of a couple of solutions:
1. Make the ISemanticModification more robust against such parse errors
2. Replace ISemanticModification by a syntactic modification (IXtextDocument.replace(...))
3. Give a pop-up to the user on execution of the quickfix if this exception occurs
4. Avoid showing the quickfix at all if there are such parse errors
Our preference would be solution 1.
Ad 1: Any suggestions how to do this?
Ad 2: We know how to this, but we conceptually prefer a semantic modification.
Ad 3: We have managed to do this (by overriding DefaultTextEditComposer)
Ad 4: Any suggestions how to do this? For example, is there a way to detect during validation whether there is a parse error (in a certain context)?
The stacktrace for the error:
!ENTRY org.eclipse.ui 4 0 2016-06-21 15:06:32.251
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.emf.common.util.WrappedException: org.eclipse.xtext.validation.IConcreteSyntaxValidator$InvalidConcreteSyntaxException: These errors need to be fixed before the model can be serialized.
Model.classes[0]->Class.methods[1]->Method'b': Feature Method.body must be set.
at org.eclipse.xtext.ui.editor.quickfix.IssueResolution.apply(IssueResolution.java:78)
at org.eclipse.xtext.ui.editor.quickfix.QuickAssistCompletionProposal.apply(QuickAssistCompletionProposal.java:33)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:968)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertSelectedProposalWithMask(CompletionProposalPopup.java:914)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$27(CompletionProposalPopup.java:910)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup$5.widgetDefaultSelected(CompletionProposalPopup.java:674)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:119)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4362)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4180)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3769)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:694)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:606)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
Caused by: org.eclipse.xtext.validation.IConcreteSyntaxValidator$InvalidConcreteSyntaxException: These errors need to be fixed before the model can be serialized.
Poosl.processClasses[0]->ProcessClass'someClass'.methods[1]->ProcessMethod'b': Feature ProcessMethod.body must be set.
at org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:129)
at org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:192)
at org.eclipse.xtext.serializer.impl.Serializer.serializeReplacement(Serializer.java:216)
at org.eclipse.xtext.ui.editor.model.edit.DefaultTextEditComposer.getObjectEdits(DefaultTextEditComposer.java:176)
at nl.esi.poosl.xtext.ui.quickfix.PooslTextEditComposer.getObjectEdits(PooslTextEditComposer.java:15)
at org.eclipse.xtext.ui.editor.model.edit.DefaultTextEditComposer.getTextEdit(DefaultTextEditComposer.java:146)
at org.eclipse.xtext.ui.editor.model.edit.DefaultTextEditComposer.endRecording(DefaultTextEditComposer.java:129)
at org.eclipse.xtext.ui.editor.model.edit.ReconcilingUnitOfWork.exec(ReconcilingUnitOfWork.java:57)
at org.eclipse.xtext.ui.editor.model.edit.ReconcilingUnitOfWork.exec(ReconcilingUnitOfWork.java:1)
at org.eclipse.xtext.resource.OutdatedStateManager.exec(OutdatedStateManager.java:98)
at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.modify(XtextDocument.java:428)
at org.eclipse.xtext.ui.editor.model.XtextDocument.internalModify(XtextDocument.java:162)
at org.eclipse.xtext.ui.editor.model.XtextDocument.modify(XtextDocument.java:155)
at org.eclipse.xtext.ui.editor.model.edit.SemanticModificationWrapper.apply(SemanticModificationWrapper.java:32)
at org.eclipse.xtext.ui.editor.quickfix.IssueResolution.apply(IssueResolution.java:76)
... 33 more
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.10574 seconds