Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » dangling reference to a derived object
dangling reference to a derived object [message #1810241] Mon, 05 August 2019 20:03 Go to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
Hello again,

I've spent the last couple of days trying to get fancy and I've potentially shot myself in the foot.

I have a situation where my DSL has a lot of derived objects that are implicitly declared. I have to dynamically derive them within my DerivedStateComputer. Which seems to be working well.

In this derivation, I can tell if a higher level object should be declared that can associate all these derived objects. The trouble is, my DSL doesn't have a declarative way declare this higher level association.

I'm am therefore creating this higher level association in a Singleton object I create on the fly. When I determine my derived objects can be associated, I get my Singleton instance and I create that association object within the Singleton.

The trouble is, other parts of my DSL need to reference these derived associations. When I do this, I get the complaint during linking/validation:

The feature 'connectionBundleRef' of XXX contains a dangling reference 'pbx.impl.ConnectionBundleImpl@fde068b{#//@connectionBundles.643}'

Somewhere else the error is more clear and indicates that the ConnectionBundleImpl is not contained in a resource - which I suppose it is not because it's derived on the fly and contained within my top level Singleton (The Singleton seems EMF enough to get a resource, but maybe not)

Is there a way to present my top level Singleton as an Xtext resource and thus "lie" to Xtext telling it these derived associated objects (ConnectionBundles) are able to be crossreference?

I have created a ResourceDescriptionStrategy to govern what objects make it into the index, but the method createEObjectDescriptions, never gets an argument e that is of the type ConnectionBundle - so I can't use my ResourceDescriptionStrategy as a way to get these objects into the Index as far as I can tell - I never get the chance to decide if they should be there or not. Which confuses me. Perhaps that's because the objects of that type are not seen as being within a Resource?
Re: dangling reference to a derived object [message #1810242 is a reply to message #1810241] Mon, 05 August 2019 20:18 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
I can also add, the my ScopProvider is accessing my Singleton, getting all the ConnectionBundles stored in it and providing the scope for these ConnectionBundleRefs "properly" - meaning when I Ctrl+Space in my editor, I see a list of sensible ConnectionBundleRefs, it's just when I choose one, the link is dangling.
Re: dangling reference to a derived object [message #1810248 is a reply to message #1810242] Tue, 06 August 2019 03:49 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Did you consider to simply turn off this validation. See Custom EObjectValidator in CompositeEValidator

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: dangling reference to a derived object [message #1810312 is a reply to message #1810248] Wed, 07 August 2019 14:00 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
That might be an alternative since I'm doing my own scoping and I could do validation too.

However, with my structure, there seems to also be a side effect that the build process isn't getting kicked off upon app launch either. I suppose since my crossReferenced items don't live in a resource, there is nothing to trigger the initial build. I'm having to do a Project->Clean in order to get the derived objects to be declared.
Re: dangling reference to a derived object [message #1810317 is a reply to message #1810312] Wed, 07 August 2019 15:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
i still have no plan what you are doing. you are way to high level / vague in your descriptions.
why should there a build if you dont change any model file


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: dangling reference to a derived object [message #1810403 is a reply to message #1810317] Fri, 09 August 2019 14:56 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
index.php/fa/36079/0/

Hopefully this picture helps.

My derived Connections are able to be added to the PBXDocuments - the documents for my DSL.

But I need to create an overall association of these derived Connections, which I call ConnectionBundles. There is no place in the DSL where these ConnectionBundles are described, so they are, indeed, not contained within an resource.

I have a DSL file that can make references to these ConnectionBundles - and thus I am referencing an Object that has easy access to all the associated Connections.

Route returns Route:
   connectionBundleRef=[ConnectionBundle|ID] ':'
   BEGIN
      'paths' ':' ((BEGIN '-' paths+=Path ('-' paths+=Path)* END) | '-' paths+=Path ('-' paths+=Path)* )
   END
;


I can scope and validate that ConnectionBundle reference, but I can't get past the dangling reference error. When I'm scoping the ConnectionBundle and Connection references in this highly cross referenced file, I simply access my pbxApp.getInstance() singleton which contains a list of derived ConnectionBundles.

I have a file that is predominantly built with crossReferences to ConnectionBundles (and the associated derived Connections). What I'm finding is when I load my application and that file is loaded, ALL references are marked as errors - all derived ConnectionBundles and Connections. The Connections are derived and contained within Resources, so I don't understand why their derivations aren't being triggered. I'm having to Project -> Clean to get any of those objects built and linked.

I can understand why the ConnectionBundles are not created, but the cross references to Connections, that are derived and contained within resources, I don't understand why the builder isn't triggering a build and creating them. Is it because there's major cross reference error before them?

This last part is why I don't know if simply turning off this dangling reference error will solve my problem (plus I haven't figured out how to turn off the error yet.)
  • Attachment: UML.PNG
    (Size: 175.91KB, Downloaded 193 times)

[Updated on: Fri, 09 August 2019 15:14]

Report message to a moderator

Re: dangling reference to a derived object [message #1810412 is a reply to message #1810403] Fri, 09 August 2019 17:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Is there any reason the on the fly is done in a global Singleton and not per resource?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: dangling reference to a derived object [message #1810413 is a reply to message #1810412] Fri, 09 August 2019 17:45 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
Christian Dietrich wrote on Fri, 09 August 2019 13:30
Is there any reason the on the fly is done in a global Singleton and not per resource?


The on the fly ConnectionBundles do not have a declarative syntax in the DSL. I can't change the DSL because I don't own its original format/syntax.

I'm trying the Singleton pattern because I can't figure out where to store the ConnectionBundle concept.

Maybe you're suggesting the resource I'm in that causes me to first derive the ConnectionBundle can be the resource that owns that ConnectionBundle - even though the ConnectionBundle is conceptually global, I can still store its derivation within the resource where I first discovered it should exist?

Once its derived (and associated with a PBXDoc), I can reference it through the index instead of grabbing it from the Singleton?
Re: dangling reference to a derived object [message #1810414 is a reply to message #1810413] Fri, 09 August 2019 18:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
what about: use iderivedstatecomputer and store it in slot 2 of the resource.contents
(as xbase/xtend do it)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: dangling reference to a derived object [message #1810426 is a reply to message #1810414] Sat, 10 August 2019 16:42 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
Interesting. When you say "slot2", so you mean "any other slot then resource.getContents().get(0)?

For example in the Xbase JvmModelAssociator, I've found code that puts stuff in the resource.contents, but doesn't put them in resource.getContents().get(0).

Example (it's more direct to see it when they are cleaning up)

EList<EObject> resourcesContentsList = resource.getContents();
		for (int i = 1; i < resourcesContentsList.size(); i++) {
			EObject eObject = resourcesContentsList.get(i);
			unloader.unloadRoot(eObject);
			derived.add(eObject);
		}


I've never thought to use items beyond resource.getContents(0), because that content element is holding the root of my DSL.

This might work if this is what you're suggesting.
Re: dangling reference to a derived object [message #1810427 is a reply to message #1810426] Sat, 10 August 2019 17:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
yes this is what i mean. a different usecase of iderivedstatecomputer is described here. it might give you hints on what to do: http://xtextcasts.org/episodes/18-model-optimization

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: dangling reference to a derived object [message #1810462 is a reply to message #1810427] Mon, 12 August 2019 12:44 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
Thanks for the help. I'm in the middle of doing it in a manner where I place the ConnectionBundles via resource.getContents().add(connBundle). I have a bug somewhere which is breaking my scoping and and proposals now. But more painfully, the performance of my app has fallen off a cliff and is just abysmal now. It's making it very painful to debug. If I breathe on any resource, the builder then proceeds to enter my DerivedStateComputer and recalculates every single thing. Using a ScopingCache to retrieve these now scattered ConnectionBundles seems to be one way to speed things up. But it's just awful at the moment. With this much pain, I may have to go back to the previous way and turn off that validation for the dangling reference.

Editing and saving an edit to a comment line is causing the builder to rebuild all my derived objects! That seems very unexpected to me. It's very painful. "Updating resource descriptions chunk 1 of 1" takes forever on any file save and calculating highlighting is very slow and locks the UI thread.

[Updated on: Mon, 12 August 2019 13:22]

Report message to a moderator

Re: dangling reference to a derived object [message #1810475 is a reply to message #1810462] Mon, 12 August 2019 14:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
i dont know what you are actually doing. so i cannot help

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: dangling reference to a derived object [message #1810477 is a reply to message #1810475] Mon, 12 August 2019 15:00 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
Could I trouble you for a bit more help or some more hints on this approach?:

> Did you consider to simply turn off this validation. See Custom EObjectValidator in CompositeEValidator
Re: dangling reference to a derived object [message #1810482 is a reply to message #1810477] Mon, 12 August 2019 15:21 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
I have doubts I can do this with my limited resources for support

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Maven build issues
Next Topic:working example connecting monaco editor with a Xtext LSP server
Goto Forum:
  


Current Time: Tue Apr 23 07:17:06 GMT 2024

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

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

Back to the top