Home » Modeling » Epsilon » [EGL] CrossReferences(Problems retrieve CrossReferences in Epsilon)
[EGL] CrossReferences [message #479593] |
Tue, 11 August 2009 12:39  |
Eclipse User |
|
|
|
Hi All
I'm using EGL to generate (hypertext) HTML presentation of Ecore model.
I would like to have at any EObject section named "Where is used" which include links to all related EObjects (not only referenced and contained - it's easy - but these pointing to this EObject too).
I have no success even I tried lot of ways how make it work:
a) if I try use eCrossReferences() method on EObject then I will get some crossreferenced EObjects to my EObject. Unfortunately I have no chance to get associated feature because EObject.eCrossReferences() returns EContentEList.FeatureIterator but Epsilon identifies answer like untyped Sequence
Example:
for (n in o.eCrossReferences()) {
n.feature(); -- undefined method
}
Maybe support of casting in Epsilon? Or possibility to include some Java code into EGL?
-----
b) I tried to use EcoreUtil.UsageCrossReferences class to retrieve dependencies but I have no more ideas how to specify and access this (static inner) class in Epsilon (EOL/EGL):
var a: EcoreUtil.UsageCrossReferences;
-- unknown class
var a: org.eclipse.emf.ecore.utils.ECoreUtil.UsageCrossReferences;
-- unknown type org
var a: "org.eclipse.emf.ecore.utils.ECoreUtil.UsageCrossReferences"
-- unknown class
var a := new Native('org.eclipse.emf.ecore.utils.ECoreUtil.UsageCrossRefe rences')
-- unknown class
Maybe some classpath and/or classloader magic ...
-----
Thanks for help and sorry for my english
Ivo(sh)
|
|
|
Re: [EGL] CrossReferences [message #479613 is a reply to message #479593] |
Tue, 11 August 2009 13:18   |
Eclipse User |
|
|
|
Hi Ivosh,
Ivosh Musil wrote:
> Hi All
>
> I'm using EGL to generate (hypertext) HTML presentation of Ecore model.
Perhaps the EGLDoc example, which also generates HTML from Ecore models,
would be useful for you? Here's a link:
http://www.eclipse.org/gmt/epsilon/examples/index.php?exampl e=org.eclipse.epsilon.examples.egldoc
>
> I would like to have at any EObject section named "Where is used" which
> include links to all related EObjects (not only referenced and contained
> - it's easy - but these pointing to this EObject too).
>
> I have no success even I tried lot of ways how make it work:
>
> a) if I try use eCrossReferences() method on EObject then I will get
> some crossreferenced EObjects to my EObject. Unfortunately I have no
> chance to get associated feature because EObject.eCrossReferences()
> returns EContentEList.FeatureIterator but Epsilon identifies answer like
> untyped Sequence
The EObject interface defines EList<EObject> as the return type of
eCrossReferences. Are you using a different implementation of EObject?
Where does the EContentEList.FeatureIterator come from?
>
> Example:
>
> for (n in o.eCrossReferences()) {
> n.feature(); -- undefined method
> }
I ran an experiment with the following EOL code on the Ecore metamodel:
EClass.all.first.println();
for (crossRef in EClass.all.first.eCrossReferences()) {
(crossRef.name + ' ' + crossRef.eClass.name).println();
}
which prints:
EClass [name=EAttribute,
instanceClassName=org.eclipse.emf.ecore.EAttribute,
instanceClass=interface org.eclipse.emf.ecore.EAttribute,
defaultValue=null, instanceTypeName=org.eclipse.emf.ecore.EAttribute,
abstract=false, interface=false, ]
EStructuralFeature EClass
name EAttribute
ordered EAttribute
unique EAttribute
lowerBound EAttribute
upperBound EAttribute
.....
ETypedElement EClass
EStructuralFeature EClass
Property 'name' not found in object EGenericType []
(/Users/louis/Code/eclipse/workspaces/galileo/runtime-epsilo n/Scratchpad/CrossRefs.eol@3:14)
The first line of output tells us that EClass.all.first returns the
EAttribute class.
The second line of output tells us that the EStructuralFeature object
(of type EClass) cross references the EAttribute class.
The third line that the name object (of type EAttribute) cross
references the EAttribute class, and so on.
Finally, we get an error because name isn't defined on EGenericType.
This could be fixed with the following EOL code, which only prints an
object's name if the name property is defined for that object:
EClass.all.first.println();
for (crossRef in EClass.all.first.eCrossReferences()) {
if (crossRef.name.isDefined) {
(crossRef.name + ' ' + crossRef.eClass.name).println();
} else {
crossRef.println();
}
}
Apologies if this explanation is not very good. I always find ECore's
self-referencing nature a little hard to describe. Let me know if this
is unclear, and I'll devise a better example that doesn't use ECore.
>
> Maybe support of casting in Epsilon? Or possibility to include some Java
> code into EGL?
A bit more information on Epsilon... EOL, and hence EGL, is dynamically
typed - types aren't checked until runtime. Casting is not necessary,
because an object's type is always known at runtime.
Cheers,
Louis.
----
Louis Rose
Research Student
Department of Computer Science,
University of York,
Heslington, York, YO10 5DD, United Kingdom.
+44 1904 434762
Twitter: @louismrose
|
|
| |
Re: [EGL] CrossReferences [message #479767 is a reply to message #479738] |
Wed, 12 August 2009 09:06   |
Eclipse User |
|
|
|
Ivosh,
Ivosh Musil wrote:
> Hi Louis
>
> thanks for your quick answer.
No problem! Thanks for the response, I think I understand the issue
better now :-)
>
> Louis Rose wrote on Tue, 11 August 2009 13:18
>> The EObject interface defines EList<EObject> as the return type of
>> eCrossReferences. Are you using a different implementation of EObject?
>> Where does the EContentEList.FeatureIterator come from?
>
>
> Please take a look at
> http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/topic/ org.eclipse.emf.doc/references/javadoc/org/eclipse/emf/ecore /EObject.html#eCrossReferences()
>
>
> It's a little messy - method eCrossReferences() returns officially
> EList<EObject> but you can cast it to its subtype
> EContentEList.FeatureIterator and use additional method feature() which
> return feature where on referencing EObject is reference to referenced
> Object:
Got it! Thanks very much. So, EOL wraps Java types. Instances of
java.lang.Iterator are wrapped to EolSequence. As
EContentEList.FeatureIterator implements Iterator, it is wrapped to an
EolSequence. Consequently, the feature() method cannot be accessed.
>
> Example:
>
> Model
> class A {
> id String nameOfA;
> }
>
> class B {
> id String nameOfB;
> ref A pointer;
> }
>
> Pseudocode:
>
> var a: A;
> a.nameOfA := 'My name is A';
> var b: B;
> b.nameOfB := 'My name is B';
> b.pointer := a;
>
> a.eCrossReferences() returns EContentEList.FeatureIterator like { b }
> but then (in Java) is possible to call method
> iterator().next().feature() which returns EReference named 'pointer'
>
> Hoped output:
>
> This object _a_ is used (referenced) in object _b_ in reference _pointer_
>
> Louis Rose wrote on Tue, 11 August 2009 13:18
>> A bit more information on Epsilon... EOL, and hence EGL, is
>> dynamically typed - types aren't checked until runtime. Casting is not
>> necessary, because an object's type is always known at runtime.
>
>
> I understood earlier that Epsilon is dynamically typed. But this (IMHO)
> dirty casting trick in EMF API is probably in pure dynamic language
> unsolvable.
I agree. It might be possible to fix this in EOL, but to solving this
problem would likely involve patching the type wrapper. I'll reply to
your original post to discuss your second approach, before we decide
whether a patch is needed.
Cheers,
Louis.
|
|
| | |
Re: [EGL] CrossReferences [message #479813 is a reply to message #479779] |
Wed, 12 August 2009 11:25  |
Eclipse User |
|
|
|
No problem. Good luck with the project. I think this plan (b) will be
successful.
Cheers,
Louis.
Ivo(sh) Musil wrote:
> Thanks Louis for your support ...
> - "casting" solution on (a) will be IMHO too complicated and unclean -
> better stop thinking about it
> - with "Java workaround via Epsilon Tool" on (b) helped me Dimitrios in
> another thread - seems that this will be right solution.
>
> THX
>
> Ivo(sh)
>
>
|
|
|
Re: [EGL] CrossReferences [message #573762 is a reply to message #479613] |
Wed, 12 August 2009 05:34  |
Eclipse User |
|
|
|
Hi Louis
thanks for your quick answer.
Louis Rose wrote on Tue, 11 August 2009 13:18
> Perhaps the EGLDoc example, which also generates HTML from Ecore models,
> would be useful for you? Here's a link:
> http://www.eclipse.org/gmt/epsilon/examples/index.php?exampl e=org.eclipse.epsilon.examples.egldoc
I know this excellent example and it was probably main invention for my HTML transformation :).
Louis Rose wrote on Tue, 11 August 2009 13:18
> The EObject interface defines EList<EObject> as the return type of
> eCrossReferences. Are you using a different implementation of EObject?
> Where does the EContentEList.FeatureIterator come from?
Please take a look at http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/topic/ org.eclipse.emf.doc/references/javadoc/org/eclipse/emf/ecore /EObject.html#eCrossReferences()
It's a little messy - method eCrossReferences() returns officially EList<EObject> but you can cast it to its subtype EContentEList.FeatureIterator and use additional method feature() which return feature where on referencing EObject is reference to referenced Object:
Example:
Model
class A {
id String nameOfA;
}
class B {
id String nameOfB;
ref A pointer;
}
Pseudocode:
var a: A;
a.nameOfA := 'My name is A';
var b: B;
b.nameOfB := 'My name is B';
b.pointer := a;
a.eCrossReferences() returns EContentEList.FeatureIterator like { b }
but then (in Java) is possible to call method iterator().next().feature() which returns EReference named 'pointer'
Hoped output:
This object _a_ is used (referenced) in object _b_ in reference _pointer_
Louis Rose wrote on Tue, 11 August 2009 13:18
> A bit more information on Epsilon... EOL, and hence EGL, is dynamically
> typed - types aren't checked until runtime. Casting is not necessary,
> because an object's type is always known at runtime.
I understood earlier that Epsilon is dynamically typed. But this (IMHO) dirty casting trick in EMF API is probably in pure dynamic language unsolvable.
I will focus more on second main way now:
Ivo.corpus.cz wrote on Tue, 11 August 2009 12:39
> I tried to use EcoreUtil.UsageCrossReferences class to retrieve dependencies but I have no more ideas how to specify and access this (static inner) class in Epsilon (EOL/EGL):
Thanks for discussing
Ivo(sh)
|
|
|
Re: [EGL] CrossReferences [message #573848 is a reply to message #573762] |
Wed, 12 August 2009 09:06  |
Eclipse User |
|
|
|
Ivosh,
Ivosh Musil wrote:
> Hi Louis
>
> thanks for your quick answer.
No problem! Thanks for the response, I think I understand the issue
better now :-)
>
> Louis Rose wrote on Tue, 11 August 2009 13:18
>> The EObject interface defines EList<EObject> as the return type of
>> eCrossReferences. Are you using a different implementation of EObject?
>> Where does the EContentEList.FeatureIterator come from?
>
>
> Please take a look at
> http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/topic/ org.eclipse.emf.doc/references/javadoc/org/eclipse/emf/ecore /EObject.html#eCrossReferences()
>
>
> It's a little messy - method eCrossReferences() returns officially
> EList<EObject> but you can cast it to its subtype
> EContentEList.FeatureIterator and use additional method feature() which
> return feature where on referencing EObject is reference to referenced
> Object:
Got it! Thanks very much. So, EOL wraps Java types. Instances of
java.lang.Iterator are wrapped to EolSequence. As
EContentEList.FeatureIterator implements Iterator, it is wrapped to an
EolSequence. Consequently, the feature() method cannot be accessed.
>
> Example:
>
> Model
> class A {
> id String nameOfA;
> }
>
> class B {
> id String nameOfB;
> ref A pointer;
> }
>
> Pseudocode:
>
> var a: A;
> a.nameOfA := 'My name is A';
> var b: B;
> b.nameOfB := 'My name is B';
> b.pointer := a;
>
> a.eCrossReferences() returns EContentEList.FeatureIterator like { b }
> but then (in Java) is possible to call method
> iterator().next().feature() which returns EReference named 'pointer'
>
> Hoped output:
>
> This object _a_ is used (referenced) in object _b_ in reference _pointer_
>
> Louis Rose wrote on Tue, 11 August 2009 13:18
>> A bit more information on Epsilon... EOL, and hence EGL, is
>> dynamically typed - types aren't checked until runtime. Casting is not
>> necessary, because an object's type is always known at runtime.
>
>
> I understood earlier that Epsilon is dynamically typed. But this (IMHO)
> dirty casting trick in EMF API is probably in pure dynamic language
> unsolvable.
I agree. It might be possible to fix this in EOL, but to solving this
problem would likely involve patching the type wrapper. I'll reply to
your original post to discuss your second approach, before we decide
whether a patch is needed.
Cheers,
Louis.
|
|
|
Re: [EGL] CrossReferences [message #573904 is a reply to message #479768] |
Wed, 12 August 2009 09:38  |
Eclipse User |
|
|
|
Thanks Louis for your support ...
- "casting" solution on (a) will be IMHO too complicated and unclean -
better stop thinking about it
- with "Java workaround via Epsilon Tool" on (b) helped me Dimitrios in
another thread - seems that this will be right solution.
THX
Ivo(sh)
|
|
|
Re: [EGL] CrossReferences [message #573952 is a reply to message #479779] |
Wed, 12 August 2009 11:25  |
Eclipse User |
|
|
|
No problem. Good luck with the project. I think this plan (b) will be
successful.
Cheers,
Louis.
Ivo(sh) Musil wrote:
> Thanks Louis for your support ...
> - "casting" solution on (a) will be IMHO too complicated and unclean -
> better stop thinking about it
> - with "Java workaround via Epsilon Tool" on (b) helped me Dimitrios in
> another thread - seems that this will be right solution.
>
> THX
>
> Ivo(sh)
>
>
|
|
|
Goto Forum:
Current Time: Tue Jul 22 19:32:35 EDT 2025
Powered by FUDForum. Page generated in 0.26914 seconds
|