[ATL] Getting value of an Attribute with reference to EAttribute metaclass [message #70048] |
Thu, 20 December 2007 12:17  |
Eclipse User |
|
|
|
Hi everyone,
I am developing a model synchronizer. I am using EMF Compare and ATL.
The problem I have is that EMF Compare metamodel has an attribute named
"attribute", it is a reference to EAttribute metaclass. The ATL compiler
raises ClassCastException because the type of attribute is EAttribute
instead of EClass.
Any ideas?
Thanks.
|
|
|
|
Re: [ATL] Getting value of an Attribute with reference to EAttribute metaclass [message #70128 is a reply to message #70088] |
Fri, 21 December 2007 04:57  |
Eclipse User |
|
|
|
Hi Ed,
As you said, this is the exact problem. I have studied it and it seems
to be an unhandled case in the Ecore Implementation.
In the class org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.java the
following code tests if the type of EStructuralFeature is EClass. This
is correct in case we are handling the Ecore model, but if we handle low
level models (like Diff.ecore) with an attribute that is a direct
reference to high level model, then the type isn't anymore EClass.
public Object dynamicGet(...
....
if (!eClass.isInstance(resolvedEObject)) {
throw new ClassCastException...
}
....
I have done a small modification in the above code and apparently EMF
handles it correctly. Here is the modification:
....
if (!eClass.isInstance(resolvedEObject) &&
!(resolvedEObject instanceof EAttribute))
....
What do you think?
Thanks.
Ed Merks escribió:
> José,
>
> I guess you mean the "attribute" EReference of type "EAttribute" in the
> diff.ecore model?
>
> <eClassifiers xsi:type="ecore:EClass" name="AttributeChange"
> eSuperTypes="#//DiffElement">
> <eStructuralFeatures xsi:type="ecore:EReference" name="attribute"
> eType="ecore:EClass
> platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//E Attribute "/>
>
> This feature is an EReference and it references the EAttribute EClass of
> the Ecore model itself. So this should properly be an EClass that can
> be cast to EClass. Maybe there's more going on than meets the eye...
>
>
> José Carlos Herrero wrote:
>> Hi everyone,
>>
>> I am developing a model synchronizer. I am using EMF Compare and ATL.
>> The problem I have is that EMF Compare metamodel has an attribute
>> named "attribute", it is a reference to EAttribute metaclass. The ATL
>> compiler raises ClassCastException because the type of attribute is
>> EAttribute instead of EClass.
>>
>> Any ideas?
>>
>> Thanks.
|
|
|
Powered by
FUDForum. Page generated in 0.04357 seconds