Error when saving a generated XMI to DSL [message #1740096] |
Tue, 09 August 2016 07:38 |
Vincent Achard Messages: 14 Registered: August 2016 |
Junior Member |
|
|
Hello,
I have a langage generated with XText, and what I try to do is to convert a DSL file into a XMI file (in order to use Sirius), and then convert it back into a DSL file. One thing to note is that when I modify the generated XMI, it implies modifications on several DSL files.
The fact is that, when I am converting back to DSL, at the moment of saving, an error occur (the stack trace is under the message).
I do not think that it is due to the conversion, since I have checked the textual xmi file, and nothing seems wrong on it. But if it is not this, then I dont see what it could be.
What I do during the second conversion is loading one of the DSL file that need to be updated, get from the XMI the new instance of the model, put it on the DSL (after deleting the old content) and then save. But the error appear for each saving.
I have never saw such error on the web, and I would reallly appreciate some help.
Thank you, and have a nice day.
Vincent
java.lang.RuntimeException: The value 'platform:/resource/_messages/Test/Mat.proto' is an invalid STRING
Semantic Object: Model.algoDef[0]->AlgoDef.includes[0]->Includes
at org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic$ExceptionThrowingAcceptor.accept(ISerializationDiagnostic.java:77)
at org.eclipse.xtext.serializer.tokens.ValueSerializer.serializeAssignedValue(ValueSerializer.java:67)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.getToken(SequenceFeeder.java:462)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:214)
at com.conti.xcit.yaaf.serializer.YaafSemanticSequencer.sequence_Includes(YaafSemanticSequencer.java:267)
at com.conti.xcit.yaaf.serializer.YaafSemanticSequencer.createSequence(YaafSemanticSequencer.java:83)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:299)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:325)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:239)
at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:401)
at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:454)
at com.conti.xcit.yaaf.serializer.YaafSemanticSequencer.sequence_AlgoDef(YaafSemanticSequencer.java:136)
at com.conti.xcit.yaaf.serializer.YaafSemanticSequencer.createSequence(YaafSemanticSequencer.java:59)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:299)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:325)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:239)
at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:401)
at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:454)
at com.conti.xcit.yaaf.serializer.YaafSemanticSequencer.sequence_Model(YaafSemanticSequencer.java:311)
at com.conti.xcit.yaaf.serializer.YaafSemanticSequencer.createSequence(YaafSemanticSequencer.java:95)
at org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:86)
at org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:109)
at org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:133)
at org.eclipse.xtext.resource.XtextResource.doSave(XtextResource.java:354)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1430)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:999)
at com.conti.xcit.yaaf.ui.sirius.XMI2Yaaf.convert(XMI2Yaaf.java:109)
at com.conti.xcit.xmitoyaaf.handlers.SampleHandler.execute(SampleHandler.java:48)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:295)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
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.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:252)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:234)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:152)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:493)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:486)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:799)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.handleWidgetSelection(HandledContributionItem.java:675)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.access$7(HandledContributionItem.java:659)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem$4.handleEvent(HandledContributionItem.java:592)
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)
|
|
|
|
Re: Error when saving a generated XMI to DSL [message #1740211 is a reply to message #1740119] |
Wed, 10 August 2016 13:44 |
Vincent Achard Messages: 14 Registered: August 2016 |
Junior Member |
|
|
Hello Christian,
I tried to see if the xmi was saved or loaded in a wrong way. It doesn't look like so, but I found something interesting while searching:
I can add an element to a DSL file at one condition: its ID must be its only set value. I can get this value from a generated XMI, or from a Factory, if it have any other set value than its ID, it will display the previous error stack.
I added a test unit below: I left (commented) the way I load a resource from a XMI file. After it, the commented part corresond to the troubling part: if I run the code as it is now, there will be no problem, but if I run the "danger" part, it will mess with the semantic object error.
My model is like
Model:
algoDef += AlgoDef*
;
AlgoDef:
(includes+=Includes)*
('component:' algo=Algo)
;
Algo:
'name:' name=ID
('authors:' authors=Authors)?
;
Includes:
'import' importURI=STRING
;
Authors:
list+=Author ((','|(', ')) list+=Author)*
;
Author:
name=STRING
;
And here is the snippet of my test code
@Inject
static Injector injector_r;
@SuppressWarnings("unused")
public static void main(String args[]) {
YaafPackage.eINSTANCE.eClass();
ProtobufPackage.eINSTANCE.eClass();
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("xmi", new XMIResourceFactoryImpl());
ResourceSet resourceSet = new ResourceSetImpl();
//Resource xmiResource = resourceSet.getResource(URI.createFileURI(new File(xmiPath).getAbsolutePath()), true);
//AlgoDef ad = ((Model) xmiResource.getContents().get(0)).getAlgoDef().get(0);
AlgoDef ad = YaafFactory.eINSTANCE.createAlgoDef();
Algo a = YaafFactory.eINSTANCE.createAlgo();
a.setName("test name");
// // Danger
// Author at = YaafFactory.eINSTANCE.createAuthor();
// at.setName("test name");
// Authors ats = YaafFactory.eINSTANCE.createAuthors();
// ats.getList().add(at);
// a.setAuthors(ats);
// // Danger
ad.setAlgo(a);
injector_r = YaafStandaloneSetup.doSetup();
YaafResourceManager manager = new YaafResourceManager();
injector_r.injectMembers(manager);
try {
manager.doSetup(args[1]);
} catch (ConfigurationException | IOException e1) {
e1.printStackTrace();
}
XtextResource xtextResource = null;
try {
xtextResource = (XtextResource) manager.loadResource(new File(yaafPath).getAbsolutePath());
} catch (ConfigurationException | IOException e1) {
e1.printStackTrace();
}
((Model) xtextResource.getContents().get(0)).getAlgoDef().add(ad);
try {
xtextResource.save(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
}
}
Thank you for your precious help,
Vincent
[Updated on: Wed, 10 August 2016 14:02] Report message to a moderator
|
|
|
|
|
|
Re: Error when saving a generated XMI to DSL [message #1740216 is a reply to message #1740215] |
Wed, 10 August 2016 14:07 |
|
does this pure java main run for you?
package org.xtext.example.mydsl1;
import java.util.Map;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.xtext.serializer.ISerializer;
import org.xtext.example.mydsl1.myDsl.Algo;
import org.xtext.example.mydsl1.myDsl.AlgoDef;
import org.xtext.example.mydsl1.myDsl.Author;
import org.xtext.example.mydsl1.myDsl.Authors;
import org.xtext.example.mydsl1.myDsl.Includes;
import org.xtext.example.mydsl1.myDsl.MyDslFactory;
import org.xtext.example.mydsl1.myDsl.MyDslPackage;
import com.google.inject.Inject;
import com.google.inject.Injector;
public class Main {
@Inject
static Injector injector_r;
@SuppressWarnings("unused")
public static void main(String args[]) {
Injector i = new MyDslStandaloneSetup().createInjectorAndDoEMFRegistration();
ISerializer s = i.getInstance(ISerializer.class);
MyDslPackage.eINSTANCE.eClass();
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("xmi", new XMIResourceFactoryImpl());
ResourceSet resourceSet = new ResourceSetImpl();
// Resource xmiResource = resourceSet.getResource(URI.createFileURI(new
// File(xmiPath).getAbsolutePath()), true);
// AlgoDef ad = ((Model)
// xmiResource.getContents().get(0)).getAlgoDef().get(0);
MyDslFactory factory = MyDslFactory.eINSTANCE;
AlgoDef ad = factory.createAlgoDef();
Algo a = factory.createAlgo();
a.setName("test_name");
// // Danger
Author at = factory.createAuthor();
at.setName("test name");
Authors ats = factory.createAuthors();
ats.getList().add(at);
a.setAuthors(ats);
// // Danger
ad.setAlgo(a);
Includes inc = factory.createIncludes();
inc.setImportURI("platform:/resource/_messages/Test/Mat.proto");
ad.getIncludes().add(inc);
System.out.println(s.serialize(ad));
}
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
|
|
|
|
|
|
Re: Error when saving a generated XMI to DSL [message #1740227 is a reply to message #1740224] |
Wed, 10 August 2016 14:43 |
Vincent Achard Messages: 14 Registered: August 2016 |
Junior Member |
|
|
I don't fully understand how does it works, but I found:
public class YaafRuntimeModule extends com.conti.xcit.yaaf.AbstractYaafRuntimeModule {
@Override public Class<? extends IValueConverterService> bindIValueConverterService() {
return YaafTerminalConverters.class;
}
@Override
public void configure(Binder binder) {
binder.bind(ILogging.class).to(CommandLineConsole.class);
super.configure(binder);
}
}
and
public class YaafTerminalConverters extends DefaultTerminalConverters{
@Inject private IStringValueConverter iStringValueConverter;
@ValueConverter(rule = "STRING")
public IValueConverter<String> STRING() {
return iStringValueConverter;
}
}
[Updated on: Fri, 12 August 2016 07:29] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03588 seconds