EMF Compare get Object Attributes [message #1062893] |
Tue, 11 June 2013 05:27  |
Eclipse User |
|
|
|
Hi there.
I've been working on my project with EMF Compare and for my purpose I need to get the name of the Object where there is a difference between two textual models.
I'd really appreciate any help from you.
Regards.
[Updated on: Thu, 13 June 2013 13:28] by Moderator
|
|
|
Re: EMF Compare get Object Attributes [message #1063429 is a reply to message #1062893] |
Thu, 13 June 2013 03:25   |
Eclipse User |
|
|
|
Hi,
I have no idea what you're trying to achieve, but I guess what you want is to retrieve info about the target of a diff. With EMF Compare 1, you will have to cast to the proper diff type (ModelElementChangeRightTarget, ModelElementChangeLeftTarget, ...), use the getter for the target element (getRightElement, getLeftElement, ...) and navigate from that element to the info you seek : getClass(), getName(), etc.
You should switch to EMF Compare 2, since exploiting the comparison result is much easier now :
IComparisonScope scope = EMFCompare.createDefaultScope(resourceSet1, resourceSet2);
Comparison comparison = EMFCompare.builder().build().compare(scope);
List<Diff> differences = comparison.getDifferences();
for (Diff diff : differences) {
if (diff instanceof ReferenceChange) {
EObject changed = ((ReferenceChange)diff).getValue();
System.out.println("Changed EObject '" + changed.getName() + "' of type : " + changed.getClass());
}
}
Laurent Goubet
Obeo
|
|
|
|
|
|
|
|
Re: EMF Compare get Object Attributes [message #1810010 is a reply to message #1809792] |
Mon, 29 July 2019 03:30  |
Eclipse User |
|
|
|
Hello,
Please create a new thread for new questions, don't resurect old ones.
You might want to look at what we're doing in org.eclipse.emf.compare.utils.EMFComparePrettyPrinter to navigate the differences and look at the documentation for the core concepts. Though incomplete, the documentation could explain what most references mean on the Diff objects. If this is not enough, please detail your questions (in a new thread).
Laurent Goubet
Obeo
|
|
|
Powered by
FUDForum. Page generated in 0.35049 seconds