Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Why does ClusteringBuilderState.writeNewResourceDescriptions copies computed IResourceDescription ?
Why does ClusteringBuilderState.writeNewResourceDescriptions copies computed IResourceDescription ? [message #1220512] Thu, 12 December 2013 09:30 Go to next message
Flo Plateau is currently offline Flo PlateauFriend
Messages: 16
Registered: December 2013
Junior Member
Hi,

I'm wondering why ClusteringBuilderState.writeNewResourceDescriptions makes a copy of the resource description it computes to perform the linking:

subMonitor.subTask("Writing new resource description for " + uri.lastSegment() + " (" + index++ + " of " + n + ")"); // TODO: NLS

final IResourceDescription.Manager manager = getResourceDescriptionManager(uri);
if (manager != null) {
  // We don't care here about links, we really just want the exported objects so that we can link in the
  // next phase.
  final IResourceDescription description = manager.getResourceDescription(resource);
  final IResourceDescription copiedDescription = new CopiedResourceDescription(description);
  // We also don't care what kind of Delta we get here; it's just a temporary transport vehicle. That interface
  // could do with some clean-up, too, because all we actually want to do is register the new resource
  // description, not the delta.
  newState.register(new DefaultResourceDescriptionDelta(oldState.getResourceDescription(uri), copiedDescription));
  buildData.queueURI(uri);
}


As my IEObjectDescriptions contain lazy fields, this copy disturbs me (actually, it causes a failure), thus if it is done only for optimization purpose, I would like to avoid it.

Thanks in advance,
Florence
Re: Why does ClusteringBuilderState.writeNewResourceDescriptions copies computed IResourceDescriptio [message #1220527 is a reply to message #1220512] Thu, 12 December 2013 11:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

you IEObjectDescriptions should not contain lazy stuff.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Why does ClusteringBuilderState.writeNewResourceDescriptions copies computed IResourceDescriptio [message #1220727 is a reply to message #1220527] Fri, 13 December 2013 10:11 Go to previous messageGo to next message
Flo Plateau is currently offline Flo PlateauFriend
Messages: 16
Registered: December 2013
Junior Member
The computation of my IEObjectDescription userData necessitates the references to be resolved, thus I cannot avoid doing it lazily (the IEObjectDescriptions are computed to perform the linking, their computation shouldn't in turn trigger the linking).
Re: Why does ClusteringBuilderState.writeNewResourceDescriptions copies computed IResourceDescriptio [message #1220738 is a reply to message #1220727] Fri, 13 December 2013 10:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
I'd is impossible to have resolved references in the indexing phase.
You could leverage nodemodel to retrieve at least the texts

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Why does ClusteringBuilderState.writeNewResourceDescriptions copies computed IResourceDescriptio [message #1220740 is a reply to message #1220727] Fri, 13 December 2013 10:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
BTW what do you need the use data for?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Why does ClusteringBuilderState.writeNewResourceDescriptions copies computed IResourceDescriptio [message #1220774 is a reply to message #1220740] Fri, 13 December 2013 14:14 Go to previous messageGo to next message
Flo Plateau is currently offline Flo PlateauFriend
Messages: 16
Registered: December 2013
Junior Member
My DSL contains functions and types. As my DSL allows to define several functions with the same name as soon as their parameters types are different, when I resolve a link to a function I have to know its parameters types, in order to choose the right target function (depending on the effective arguments types).

That is why I store the parameters types in the user data of the functions IEObjectDescriptions. I cannot use the text of the type, available in the node model, because my DSL allows to define alias types, and I have to store the normalized version of the parameters types. To this end, I have to resolve the type references to see in the type declaration if it is an alias to another type. That is why the user data of my functions IEObjectDescriptions is stored in a lazy field (the IEObjectDescriptions are computed to prepare the link phase, it should not trigger it).

All this worked fine until I started to use a Control Version System to manage the code I write with my DSL. When I update the code (and thus modify it outside eclipse), the next build raises a ClassCastException because of some encoded xtext links that seem to be outdated w.r.t. the new version of the files. This exception occurs during the computation of the lazy user data of my functions, itself triggered by the IEObjectDescriptions copy performed in ClusteringBuilderState.writeNewResourceDescriptions. Everything seems to work fine if I remove the call to new CopiedResourceDescription(description). But as I don't understand the role of this copy, I'm afraid to be missing something. That's why I asked some explanations about this copy.
Re: Why does ClusteringBuilderState.writeNewResourceDescriptions copies computed IResourceDescriptio [message #1220781 is a reply to message #1220774] Fri, 13 December 2013 14:46 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
HI,

i dont know this but i think the reason is to have them readonly after creation.
Maybe you could use IDerivedStateComputer to place additional information
http://xtextcasts.org/episodes/18-model-optimization


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Why does ClusteringBuilderState.writeNewResourceDescriptions copies computed IResourceDescriptio [message #1220916 is a reply to message #1220727] Mon, 16 December 2013 07:24 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
We use a forwarding map in
org.eclipse.xtext.common.types.descriptions.JvmTypesResourceDescriptionStrategy

In the index it will be called during indexing where you might not be
able to resolve eveyrthing at that point. But the result will be
discarded and computed again in the linking phase.

To avoid that useless computation you could also ask CompilerPhases
whether we are in the indexing phase. And then simply don'T do the
computation of user data.

hth,
Sven

Am 12/13/13 11:11 AM, schrieb Flo Plateau:
> The computation of my IEObjectDescription userData necessitates the
> references to be resolved, thus I cannot avoid doing it lazily (the
> IEObjectDescriptions are computed to perform the linking, their
> computation shouldn't in turn trigger the linking).


--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
Re: Why does ClusteringBuilderState.writeNewResourceDescriptions copies computed IResourceDescriptio [message #1220948 is a reply to message #1220781] Mon, 16 December 2013 10:11 Go to previous messageGo to next message
Flo Plateau is currently offline Flo PlateauFriend
Messages: 16
Registered: December 2013
Junior Member
Ok, thank you (I don't think I can use the IDerivedStateComputer as computing my additional information necessitates some link to be resolved).
Re: Why does ClusteringBuilderState.writeNewResourceDescriptions copies computed IResourceDescriptio [message #1220953 is a reply to message #1220916] Mon, 16 December 2013 10:58 Go to previous messageGo to next message
Flo Plateau is currently offline Flo PlateauFriend
Messages: 16
Registered: December 2013
Junior Member
(my previous post was an answer to Christian)

I was not aware of the existence of ForwardingMap, indeed I could have used it. I think my implementation has the same behaviour concerning the lazyness.

Could you give me more precisions about CompilerPhases ? I don't find any class with this name nor any field named like that in the DefaultResourceDescriptionStrategy context.
Re: Why does ClusteringBuilderState.writeNewResourceDescriptions copies computed IResourceDescriptio [message #1222366 is a reply to message #1220953] Fri, 20 December 2013 08:51 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
It has been added in 2.5.0.

Am 16/12/13 11:58, schrieb Flo Plateau:
> (my previous post was an answer to Christian)
>
> I was not aware of the existence of ForwardingMap, indeed I could have
> used it. I think my implementation has the same behaviour concerning the
> lazyness.
>
> Could you give me more precisions about CompilerPhases ? I don't find
> any class with this name nor any field named like that in the
> DefaultResourceDescriptionStrategy context.
>


--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
Re: Why does ClusteringBuilderState.writeNewResourceDescriptions copies computed IResourceDescriptio [message #1222469 is a reply to message #1222366] Fri, 20 December 2013 13:59 Go to previous message
Flo Plateau is currently offline Flo PlateauFriend
Messages: 16
Registered: December 2013
Junior Member
Thank you for your answer, I'm going to update to 2.5.0.
Previous Topic:Xtend To UML generator
Next Topic:Generate artefacts with gradle
Goto Forum:
  


Current Time: Fri Apr 19 00:44:24 GMT 2024

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

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

Back to the top