Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » [EGL] CrossReferences
[EGL] CrossReferences [message #573719] Tue, 11 August 2009 16:39 Go to next message
Ivo(sh) Musil is currently offline Ivo(sh) MusilFriend
Messages: 17
Registered: July 2009
Junior Member
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 #573741 is a reply to message #573719] Tue, 11 August 2009 17:18 Go to previous messageGo to next message
Louis Rose is currently offline Louis RoseFriend
Messages: 440
Registered: July 2009
Location: York, United Kingdom
Senior Member
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 #573883 is a reply to message #573719] Wed, 12 August 2009 13:09 Go to previous message
Louis Rose is currently offline Louis RoseFriend
Messages: 440
Registered: July 2009
Location: York, United Kingdom
Senior Member
Ivosh,

As promised, comments on plan (b)...

> 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 ...

Given the problems you highlight with approach (a), this seems like a
good alternative.

I think that you've already discovered how to load this class - use an
Epsilon tool. Do post again if you have any further troubles getting
this to work.

Cheers,
Louis.
Previous Topic:Preconditions and postconditions for operations and ErlParserRules.g
Next Topic:Trouble accessing java objects
Goto Forum:
  


Current Time: Tue Apr 23 08:22:28 GMT 2024

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

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

Back to the top