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 10:49 Go to next message
leonard.krpan is currently offline leonard.krpan
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 11:34 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25952
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) {
>
Previous Topic:[EEF] Issue with Map$Entry
Next Topic:[Debugging Ecore model loading] code execution hangs in debug mode
Goto Forum:
  


Current Time: Sat Aug 02 02:43:14 EDT 2014

Powered by FUDForum. Page generated in 0.04051 seconds