Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » none elements for CrossReferencer-Iterator
none elements for CrossReferencer-Iterator [message #652221] Thu, 03 February 2011 08:05 Go to next message
AJ  is currently offline AJ Friend
Messages: 77
Registered: July 2009
Member
I have these 2 resources (see below) under the same ResourceSet:

<?xml version="1.0" encoding="ASCII"?>
<org.eclipse.emf.crossdocument:EPlan xmlns:org.eclipse.emf.crossdocument=" platform:/resource/org.eclipse.emf.crossdocument/model/Plann ing.ecore ">
<children name="ELEMENT1">
<data href="Resource2.data#/0"/>
</children>
<children name="ELEMENT2">
<data href="Resource2.data#/1"/>
</children>
</org.eclipse.emf.crossdocument:EPlan>

<?xml version="1.0" encoding="ASCII"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:org.eclipse.emf.crossdocument=" platform:/resource/org.eclipse.emf.crossdocument/model/Data. ecore ">
<org.eclipse.emf.crossdocument:Order number="12345"/>
<org.eclipse.emf.crossdocument:Order number="99999"/>
</xmi:XMI>

-----------------------------

However, when I call EcoreUtil.delete(element1, true), EcoreUtil.eCrossReferences() always returns an empty list so the target is never removed and I end with this:

<?xml version="1.0" encoding="ASCII"?>
<org.eclipse.emf.crossdocument:EPlan xmlns:org.eclipse.emf.crossdocument=" platform:/resource/org.eclipse.emf.crossdocument/model/Plann ing.ecore ">
<children name="ELEMENT2">
<data href="Resource2.data#/1"/>
</children>
</org.eclipse.emf.crossdocument:EPlan>

<?xml version="1.0" encoding="ASCII"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:org.eclipse.emf.crossdocument=" platform:/resource/org.eclipse.emf.crossdocument/model/Data. ecore ">
<org.eclipse.emf.crossdocument:Order number="12345"/>
<org.eclipse.emf.crossdocument:Order number="99999"/>
</xmi:XMI>

-----------------

Note: Containment Proxies was set to true when I generated the code.

Any idea why EcoreUtil.eCrossReferences() returns an empty list?
Re: none elements for CrossReferencer-Iterator [message #652245 is a reply to message #652221] Thu, 03 February 2011 10:27 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30541
Registered: July 2009
Senior Member
AJ,

Comments below.

AJ wrote:
> I have these 2 resources (see below) under the same ResourceSet:
>
> <?xml version="1.0" encoding="ASCII"?>
> <org.eclipse.emf.crossdocument:EPlan
> xmlns:org.eclipse.emf.crossdocument="
> platform:/resource/org.eclipse.emf.crossdocument/model/Plann ing.ecore ">
> <children name="ELEMENT1">
> <data href="Resource2.data#/0"/>
> </children>
> <children name="ELEMENT2">
> <data href="Resource2.data#/1"/>
> </children>
> </org.eclipse.emf.crossdocument:EPlan>
>
> <?xml version="1.0" encoding="ASCII"?>
> <xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:org.eclipse.emf.crossdocument="
> platform:/resource/org.eclipse.emf.crossdocument/model/Data. ecore ">
> <org.eclipse.emf.crossdocument:Order number="12345"/>
> <org.eclipse.emf.crossdocument:Order number="99999"/>
> </xmi:XMI>
>
> -----------------------------
>
> However, when I call EcoreUtil.delete(element1, true),
> EcoreUtil.eCrossReferences() always returns an empty list so the
> target is never removed and I end with this:
>
> <?xml version="1.0" encoding="ASCII"?>
> <org.eclipse.emf.crossdocument:EPlan
> xmlns:org.eclipse.emf.crossdocument="
> platform:/resource/org.eclipse.emf.crossdocument/model/Plann ing.ecore ">
> <children name="ELEMENT2">
> <data href="Resource2.data#/1"/>
> </children>
> </org.eclipse.emf.crossdocument:EPlan>
>
> <?xml version="1.0" encoding="ASCII"?>
> <xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:org.eclipse.emf.crossdocument="
> platform:/resource/org.eclipse.emf.crossdocument/model/Data. ecore ">
> <org.eclipse.emf.crossdocument:Order number="12345"/>
> <org.eclipse.emf.crossdocument:Order number="99999"/>
> </xmi:XMI>
That's what I would expect.
>
> -----------------
>
> Note: Containment Proxies was set to true when I generated the code.
>
> Any idea why EcoreUtil.eCrossReferences() returns an empty list?
I'm not sure what you're referring to with this.
Re: none elements for CrossReferencer-Iterator [message #652339 is a reply to message #652245] Thu, 03 February 2011 15:54 Go to previous messageGo to next message
AJ  is currently offline AJ Friend
Messages: 77
Registered: July 2009
Member
Ed,

But if the contained target had been in the same resource, then it would have been deleted when his container (ELEMENT1) was deleted. So, shouldn't the target object (<data href="Resource2.data#/0"/>) be removed from Resource2 as well?
Re: none elements for CrossReferencer-Iterator [message #652354 is a reply to message #652339] Thu, 03 February 2011 16:25 Go to previous messageGo to next message
AJ  is currently offline AJ Friend
Messages: 77
Registered: July 2009
Member
To add to my previous comment.

After saving both resource, if I call EObject container = target1.eContainer(); then ELEMENT1 is returned.

And if I called target1.eContainer() again after I have called EcoreUtil.delete(element1, true), then container is now null (which is good). However, the target is now an orphan in Resource2 (it doesn't have a container in Resource1).

My best friend, the debugger, is the one telling me that the target was not removed from Resource2 because EcoreUtil.handleCrossReference() doesn't find any cross references.
Re: none elements for CrossReferencer-Iterator [message #652424 is a reply to message #652339] Thu, 03 February 2011 20:01 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30541
Registered: July 2009
Senior Member
AJ,

Comments below.

AJ wrote:
> Ed,
>
> But if the contained target had been in the same resource, then it
> would have been deleted when his container (ELEMENT1) was deleted.
Yes.
> So, shouldn't the target object (<data href="Resource2.data#/0"/>) be
> removed from Resource2 as well?
No because your if statement isn't true. It's behaving exactly as
documented.

* If recursive true, contained children of the object that are in the
same resource
* are similarly removed from any features that references them.
Re: none elements for CrossReferencer-Iterator [message #652425 is a reply to message #652354] Thu, 03 February 2011 20:04 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30541
Registered: July 2009
Senior Member
AJ,

Comments below.

AJ wrote:
> To add to my previous comment.
>
> After saving both resource, if I call EObject container =
> target1.eContainer(); then ELEMENT1 is returned.
>
> And if I called target1.eContainer() again after I have called
> EcoreUtil.delete(element1, true), then container is now null (which is
> good). However, the target is now an orphan in Resource2 (it doesn't
> have a container in Resource1).
Yes, I'd expect that.
>
> My best friend, the debugger, is the one telling me that the target
> was not removed from Resource2 because
> EcoreUtil.handleCrossReference() doesn't find any cross references.
The delete method is documented to behave as you describe. That's why
we go through the effort of computing eObjects/crossResourceEObjects the
way we do.
Previous Topic:Handling saving/ dirty state over multiple files
Next Topic:EObject#eSet and autoboxing
Goto Forum:
  


Current Time: Mon Oct 14 23:05:51 GMT 2019

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

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

Back to the top