dangling reference to a derived object [message #1810241] |
Mon, 05 August 2019 20:03 |
Brandon Lewis 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 #1810403 is a reply to message #1810317] |
Fri, 09 August 2019 14:56 |
Brandon Lewis Messages: 268 Registered: May 2012 |
Senior Member |
|
|
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 197 times)
[Updated on: Fri, 09 August 2019 15:14] Report message to a moderator
|
|
|
|
|
|
|
|
Re: dangling reference to a derived object [message #1810462 is a reply to message #1810427] |
Mon, 12 August 2019 12:44 |
Brandon Lewis 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
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05200 seconds