Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Best Solution for when ISemanticModification quickfix results in an InvalidConcreteSyntaxException
Best Solution for when ISemanticModification quickfix results in an InvalidConcreteSyntaxException [message #1735647] Tue, 21 June 2016 15:02 Go to next message
Koen Staal is currently offline Koen StaalFriend
Messages: 70
Registered: October 2014
Member
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
Re: Best Solution for when ISemanticModification quickfix results in an InvalidConcreteSyntaxExcepti [message #1735651 is a reply to message #1735647] Tue, 21 June 2016 15:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13715
Registered: July 2009
Senior Member
i dont get your first point:

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.

says: you try to serialize a method with no body.

so the model is already broken before you execute the quickfix? what kind of quickfix is that? what does it do?
should it work on a broken model at all?

i guess the only proper way is to do either a IModification on the document
or not to execute any fix at all.


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Best Solution for when ISemanticModification quickfix results in an InvalidConcreteSyntaxExcepti [message #1736144 is a reply to message #1735651] Mon, 27 June 2016 06:57 Go to previous messageGo to next message
Koen Staal is currently offline Koen StaalFriend
Messages: 70
Registered: October 2014
Member
The model is indeed already broken before the execute of the quickfix.
The quickfix that is performed is related to another issue in the model and should be able to be applied.

A syntactic modification is possible with the IModification (maybe the only solution) but we want to explore all options.
Maybe not show semantic modifications if they can't be executed anyway (option 4)




Re: Best Solution for when ISemanticModification quickfix results in an InvalidConcreteSyntaxExcepti [message #1736146 is a reply to message #1736144] Mon, 27 June 2016 07:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13715
Registered: July 2009
Senior Member
i think you could check for errors in the quickfix provider for 4

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Best Solution for when ISemanticModification quickfix results in an InvalidConcreteSyntaxExcepti [message #1737478 is a reply to message #1736146] Fri, 08 July 2016 14:35 Go to previous message
Koen Staal is currently offline Koen StaalFriend
Messages: 70
Registered: October 2014
Member
That is possible, but the downside is that quickfix then already is shown to the user as an option. In this case the user will then try to execute the quickfix and it can not be applied, is a bit of a let down for the user.
Previous Topic:Convert xtext code to JavaScript
Next Topic:MWE2 Fragments for specifying injections in the MWE2 script
Goto Forum:
  


Current Time: Thu Jan 21 12:42:37 GMT 2021

Powered by FUDForum. Page generated in 0.02305 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top