|
|
Re: Serializing cross-references with Serializer2 [message #1739027 is a reply to message #1739019] |
Wed, 27 July 2016 04:59 |
|
Hi,
i cannot following you
(0) which serializer do you configure in your workflow
(1) you dont need an existing bindXXX or configureXXX or provideXXX method to customize binding. just add your own method.
(2) the Cross Reference Serializer used in the new Serializer is a subclass of org.eclipse.xtext.serializer.tokens.ICrossReferenceSerializer, the default impl org.eclipse.xtext.serializer.tokens.CrossReferenceSerializer. it will be called when you actually serialize a model with cross refs
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
|
|
|
|
|
Re: Serializing cross-references with Serializer2 [message #1739115 is a reply to message #1739097] |
Wed, 27 July 2016 15:07 |
|
from this message i dont see where the cross ref serializer is involved
Model:
greetings+=Greeting*;
Greeting:
'Hello' name=ID ('from' from=[Greeting])?'!';
public class MyDslCRS extends CrossReferenceSerializer {
@Override
public boolean isValid(EObject semanticObject, CrossReference crossref, EObject target, INode node,
Acceptor errors) {
System.out.println("isValid");
return super.isValid(semanticObject, crossref, target, node, errors);
}
@Override
public String serializeCrossRef(EObject semanticObject, CrossReference crossref, EObject target, INode node,
Acceptor errors) {
System.out.println("serialize");
return super.serializeCrossRef(semanticObject, crossref, target, node, errors);
}
}
class MyDslRuntimeModule extends AbstractMyDslRuntimeModule {
def Class<? extends ICrossReferenceSerializer> bindICrossReferenceSerializer() {
MyDslCRS
}
}
class Main {
def static void main(String[] args) {
val i = new MyDslStandaloneSetup().createInjectorAndDoEMFRegistration
val rs = i.getInstance(ResourceSet)
val r = rs.createResource(URI.createURI("demo.mydsl2"))
val model = MyDslFactory.eINSTANCE.createModel => [
val g1 = MyDslFactory.eINSTANCE.createGreeting => [
name = "g1"
]
val g2 = MyDslFactory.eINSTANCE.createGreeting => [
name = "g2"
from = g1
]
greetings += g1
greetings += g2
]
r.contents += model
r.save(SaveOptions.defaultOptions.toOptionsMap)
}
}
the value aboout the resource comes from ???
XMLSaveImpl does not sound like eclipse? sure you did not acidentally called standaloensetup from eclipse?
then it would be interesting: is this called from eclipse or is this called from standalone.
if from eclipse did you use LiveScopeResourceSetInitializer to init your resourceset
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
|
|
|
Re: Serializing cross-references with Serializer2 [message #1739118 is a reply to message #1739115] |
Wed, 27 July 2016 15:17 |
Ernesto Posse Messages: 438 Registered: March 2011 |
Senior Member |
|
|
Sorry, I think we got messages posted at the same time.
Yes, the XMLSaveImpl was misleading. I forgot I was serializing the model as an XML resource before invoking the serialization on the XtextResource.
Nevertheless, ignoring that, I still have a problem, as explained in my last message:
The failure occurs very early, in org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(ISerializationContext, EObject), when the EObject is the root element of the model, and it is caused because the call
List<TraceItem> trace = new NfaUtil().backtrack(nfa, co, new NfaUtil.BacktrackHandler<ISemState, TraceItem>() ...
returns null.
So I was wondering if there is a particular pattern in a grammar that makes this backtracking fail, or if there was a description somewhere about this backtracking mechanism in serialization, so I can figure it out.
Thanks
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05615 seconds