|
|
|
|
|
Re: using UUIDs in FragmentProvider [message #1130337 is a reply to message #1130280] |
Wed, 09 October 2013 12:59 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Benoit,
The fragment provider would need to compute the fragment value from
information available in your Xtext-based model, so unless your
Xtext-based model somehow specifies UUIDs in the syntax, I don't think
this is possible. After all, while something like an XMIResourceImpl
can assign UUIDs automatically, those UUIDs are part of the
serialization of the model, so if you wanted something similar for
Xtext, there too, the UUIDs or whatever information you want to use for
the fragment would need to be part of the serialization...
On 09/10/2013 1:47 PM, Benoit Ries wrote:
> Hi Christian,
>
> actually I think this is the other way around. I have a non-xtext
> model in which I reference xtext EObjects.
>
> This is the exact topic of the section "Fragment Provider (Referencing
> Xtext Models From Other EMF Artifacts)" in the Xtext documentation.
>
> In the xtext doc it is mentioned the following "[...] With an XMI or
> other binary-like serialization it is also common and possible to use
> UUIDs [...]"
>
> So in the doc, it says it is common and possible to use UUIDs but I
> don't have any clue on how to get started.
>
> My question is :
>
> How do I setup my DSL to use UUIDs in my DSL's fragment provider ?
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: using UUIDs in FragmentProvider [message #1138663 is a reply to message #1130285] |
Tue, 15 October 2013 08:33 |
Benoit Ries Messages: 86 Registered: May 2013 |
Member |
|
|
Hi Christian, Ed,
I'm following up on this post.
I started the implementation for this issue on giving uuids values to my EObjects. I have added a new attribute "uuid" to my EObject in my DSL's metamodel.
For now what I do is the code below. But the problem is that the value of uuid is not stable and is regenerated every time I access it.
So I guess that the value should not be initialized in this method.
My question is => Where can I initialize the uuid values of my EObjects ??
***
public String getFragment(EObject obj, Fallback fallback) {
String uuid = "";
if (obj instanceof PackageDeclaration) {
PackageDeclaration packageDeclaration = (PackageDeclaration) obj;
if (packageDeclaration.getUuid() == null
|| (packageDeclaration.getUuid() != null
&& packageDeclaration.getUuid().equals(""))) {
packageDeclaration.setUuid(EcoreUtil.generateUUID());
}
uuid = packageDeclaration.getUuid();
}
return !uuid.equals("")? uuid : fallback.getFragment(obj);
}
***
[Updated on: Tue, 15 October 2013 08:41] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04221 seconds