Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Ecore] fully qualified name for EObject type
[Ecore] fully qualified name for EObject type [message #662158] Tue, 29 March 2011 14:49 Go to next message
leonard.krpan is currently offline leonard.krpanFriend
Messages: 20
Registered: March 2011
Junior Member
Hello,

I'm dealing with a situation where my model is run through a customized generator. There's code in the generator that should output a fully qualified name of the type of a method argument. In case the type is EObject (which can be retraced to the superclass of my model's class and which I am setting programmatically), the "fully qualified name I get" is ecore.EObject, which causes a compiling error. How can I get to org.eclipse.emf.ecore EObject?

Here's the code in question:

Me setting the supertype manually:
ecClass.getESuperTypes().add(EcorePackage.Literals.EOBJECT);


Eventually the class from is processed here:
for (EClass ecls : allClasses) {
				out.println("public T case" + ecls.getName() + "(" + fullyQualifiedName(ecls) + " o) {");
...




private String fullyQualifiedName(EPackage pkg) {

	return pkg.getESuperPackage() == null ? pkg.getName() : fullyQualifiedName(pkg.getESuperPackage()) + "." + pkg.getName();
}

private String fullyQualifiedName(EClassifier cls) {
	return fullyQualifiedName(cls.getEPackage()) + "." + cls.getName();
}


resulting code:
public T caseEObject(ecore.EObject o) {
Re: [Ecore] fully qualified name for EObject type [message #662170 is a reply to message #662158] Tue, 29 March 2011 15:34 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33217
Registered: July 2009
Senior Member
Comments below.

lk_muc wrote:
> Hello,
>
> I'm dealing with a situation where my model is run through a
> customized generator. There's code in the generator that should output
> a fully qualified name of the type of a method argument. In case the
> type is EObject (which can be retraced to the superclass of my model's
> class and which I am setting programmatically), the "fully qualified
> name I get" is ecore.EObject, which causes a compiling error. How can
> I get to org.eclipse.emf.ecore EObject?
A generator should be using the GenModel in general. You might cheat
and use getInstanceType(), but that will be null if the models isn't a
generated one.
>
> Here's the code in question:
>
> Me setting the supertype manually:
>
> ecClass.getESuperTypes().add(EcorePackage.Literals.EOBJECT);
>
>
> Eventually the class from is processed here:
>
> for (EClass ecls : allClasses) {
> out.println("public T case" + ecls.getName() + "(" +
> fullyQualifiedName(ecls) + " o) {");
> ..
>
>
>
>
>
> private String fullyQualifiedName(EPackage pkg) {
>
> return pkg.getESuperPackage() == null ? pkg.getName() :
> fullyQualifiedName(pkg.getESuperPackage()) + "." + pkg.getName();
> }
>
> private String fullyQualifiedName(EClassifier cls) {
> return fullyQualifiedName(cls.getEPackage()) + "." + cls.getName();
> }
>
>
> resulting code:
>
> public T caseEObject(ecore.EObject o) {
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[EEF] Issue with Map$Entry
Next Topic:[Debugging Ecore model loading] code execution hangs in debug mode
Goto Forum:
  


Current Time: Mon Sep 23 07:19:52 GMT 2024

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

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

Back to the top