Skip to main content



      Home
Home » Modeling » TMF (Xtext) » I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBject(I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBject)
I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBject [message #1723506] Tue, 16 February 2016 04:50 Go to next message
Eclipse UserFriend
I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBject itself

Of course MyOwnEObject will extend EObject also, but i need to add some data members to all my emf objects

Thanks

[Updated on: Tue, 16 February 2016 04:55] by Moderator

Re: I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBje [message #1723507 is a reply to message #1723506] Tue, 16 February 2016 05:01 Go to previous messageGo to next message
Eclipse UserFriend
hi which xtext version do you use?
Re: I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBje [message #1723508 is a reply to message #1723506] Tue, 16 February 2016 05:02 Go to previous messageGo to next message
Eclipse UserFriend
It is possible, to change the super type in the genmodel.
But than you can no longer use the generated ecore feature in your Xtext grammar, but have to switch to an imported one.

Sven
Re: I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBje [message #1723509 is a reply to message #1723508] Tue, 16 February 2016 05:07 Go to previous messageGo to next message
Eclipse UserFriend
@Sven couldnt one subclass EmfGeneratorFragment(2) and override getGenModel
and set the genmodels rootExtendsClass
Re: I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBje [message #1723514 is a reply to message #1723509] Tue, 16 February 2016 05:29 Go to previous messageGo to next message
Eclipse UserFriend
Christian Dietrich wrote on Tue, 16 February 2016 11:07
@Sven couldnt one subclass EmfGeneratorFragment(2) and override getGenModel
and set the genmodels rootExtendsClass


Yes, that should work as well.
Re: I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBje [message #1723516 is a reply to message #1723514] Tue, 16 February 2016 05:49 Go to previous messageGo to next message
Eclipse UserFriend
I am using version 2.8
Re: I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBje [message #1723517 is a reply to message #1723516] Tue, 16 February 2016 06:02 Go to previous messageGo to next message
Eclipse UserFriend
kimi raikonnan <forums-noreply@xxxxxxxx> wrote:
> I am using version 2.8
>

Then you can try the subclass emfgeneratorfragment Approach
Re: I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBje [message #1723530 is a reply to message #1723517] Tue, 16 February 2016 07:07 Go to previous messageGo to next message
Eclipse UserFriend
I tried the solution this way

public class myEObject extends MinimalEObjectImpl {
public static class myContainer extends Container {
}
}

public class MyEMFGeneratorFragment extends EMFGeneratorFragment {
protected GenModel getGenModel(ResourceSet rs, Grammar grammar, XpandExecutionContext ctx, List<EPackage> packs) {
GenModel genModel = super.getGenModel(rs, grammar, ctx, packs);
genModel.setRootExtendsClass("com.dsl.ecasst.xtext.dsl.myEObject$myContainer");
return genModel;
}
}

in GenerateDSL.mwe2

fragment = MyEMFGeneratorFragment auto-inject {
}

but i got this exception while generation

EvaluationException : No Definition com::dsl::ecasst::xtext::dsl::MyEMFGeneratorFragment::generate(String) for org::eclipse::xtext::impl::GrammarImpl could be found!
Internal error : element was null

at org.eclipse.xpand2.XpandFacade.evaluate2(XpandFacade.java:59)
at org.eclipse.xtext.generator.AbstractGeneratorFragment.generate(AbstractGeneratorFragment.java:49)
at org.eclipse.xtext.generator.ecore.EMFGeneratorFragment.generate(EMFGeneratorFragment.java:250)
at com.dsl.ecasst.xtext.dsl.MyEMFGeneratorFragment.generate(MyEMFGeneratorFragment.java:24)
at org.eclipse.xtext.generator.DefaultGeneratorFragment.generate(DefaultGeneratorFragment.java:167)
at org.eclipse.xtext.generator.CompositeGeneratorFragment.generate(CompositeGeneratorFragment.java:163)
at org.eclipse.xtext.generator.Generator.generate(Generator.java:555)
at org.eclipse.xtext.generator.Generator.invokeInternal(Generator.java:172)
at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:35)
at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:102)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:78)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:36)
100845 [main] INFO or.validation.JavaValidatorFragment - generating Java-based EValidator API

I think i am missing something

[Updated on: Tue, 16 February 2016 07:08] by Moderator

Re: I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBje [message #1723531 is a reply to message #1723530] Tue, 16 February 2016 07:14 Go to previous messageGo to next message
Eclipse UserFriend
hi you have to override getTemplate as well and return
EMFGeneratorFragment.class.getName().....

instead of

getClass().getName() .....
Re: I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBje [message #1723533 is a reply to message #1723531] Tue, 16 February 2016 07:43 Go to previous messageGo to next message
Eclipse UserFriend
Sorry but i got the error below
is it because i but the code below without any attributes in GenerateDSL.mwe2?

fragment = MyEMFGeneratorFragment auto-inject {
}

9359 [main] INFO clipse.emf.mwe.utils.GenModelHelper - Registered GenModel 'http://www.dsl.com/ecasst/xtext/dsl/DSL' from 'platform:/resource/com.dsl.ecasst.xtext.dsl/model/generated/DSL.genmodel'
java.io.FileNotFoundException: ..\com.dsl.ecasst.xtext.dsl\build.properties (Access is denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at org.eclipse.xtext.generator.ecore.EMFGeneratorFragment.updateBuildProperties(EMFGeneratorFragment.java:284)
at org.eclipse.xtext.generator.ecore.EMFGeneratorFragment.generate(EMFGeneratorFragment.java:255)
at org.eclipse.xtext.generator.DefaultGeneratorFragment.generate(DefaultGeneratorFragment.java:167)
at org.eclipse.xtext.generator.CompositeGeneratorFragment.generate(CompositeGeneratorFragment.java:163)
at org.eclipse.xtext.generator.Generator.generate(Generator.java:555)
at org.eclipse.xtext.generator.Generator.invokeInternal(Generator.java:172)
at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:35)
at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:102)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:78)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:36)

[Updated on: Tue, 16 February 2016 07:43] by Moderator

Re: I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBje [message #1723534 is a reply to message #1723533] Tue, 16 February 2016 07:51 Go to previous messageGo to next message
Eclipse UserFriend
sorry i cannot reproduce that

public class MyEmfGeneratorFragment extends EMFGeneratorFragment {
	
	@Override
	protected String getTemplate() {
		return EMFGeneratorFragment.class.getName().replaceAll("\\.", "::");
	}
	
	@Override
	protected GenModel getGenModel(ResourceSet rs, Grammar grammar, XpandExecutionContext ctx, List<EPackage> packs) {
		// TODO Auto-generated method stub
		GenModel genModel = super.getGenModel(rs, grammar, ctx, packs);
		genModel.setRootExtendsClass("org.xtext.example.mydsl.myEObject$container");
		return genModel;
	}

}

did you debug the code?
Re: I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBje [message #1723535 is a reply to message #1723534] Tue, 16 February 2016 08:13 Go to previous messageGo to next message
Eclipse UserFriend
I solved this issue, it was my mistake.
And the generated classes inheriting myEObject.myContainer but the class myEObject is not imported in the generated class??!

class XTDeclImpl extends myEObject.myContainer {
}

the file is missing import statement for myEObject
Re: I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBje [message #1723541 is a reply to message #1723535] Tue, 16 February 2016 08:45 Go to previous messageGo to next message
Eclipse UserFriend
sry have no idea on that, maybe a question for the emf forum.
Re: I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBje [message #1723555 is a reply to message #1723541] Tue, 16 February 2016 09:48 Go to previous messageGo to next message
Eclipse UserFriend
is it reproducible from your side ?
Re: I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBje [message #1723556 is a reply to message #1723555] Tue, 16 February 2016 09:51 Go to previous messageGo to next message
Eclipse UserFriend
yes it is. but i dont know how to solve it, what is you please the class in a package that fits?
Re: I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBje [message #1723558 is a reply to message #1723556] Tue, 16 February 2016 09:56 Go to previous messageGo to next message
Eclipse UserFriend
genModel.setRootExtendsClass("org.xtext.example.mydsl.myDsl.impl.MyEObject$MyContainer");


ackage org.xtext.example.mydsl.myDsl.impl;

import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

public class MyEObject extends MinimalEObjectImpl {
public static class MyContainer extends Container {
}
Re: I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBje [message #1723569 is a reply to message #1723558] Tue, 16 February 2016 10:40 Go to previous messageGo to next message
Eclipse UserFriend
Sorry i dont understand the question
Re: I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBje [message #1723570 is a reply to message #1723569] Tue, 16 February 2016 10:46 Go to previous messageGo to next message
Eclipse UserFriend
kimi raikonnan <forums-noreply@xxxxxxxx> wrote:
> Sorry i dont understand the question
>

If there is no import what about taking care that your superclass and the
generated classes are in the same package. Since Java needs no import for
the same package it will find the super type. Thus imply move the
superclass to the mydsl.myDsl.impl class
Re: I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBje [message #1725404 is a reply to message #1723570] Thu, 03 March 2016 05:17 Go to previous messageGo to next message
Eclipse UserFriend
Hi
I am getting this error in generation

generate:
[java] 0 ERROR Mwe2Launcher - [XtextLinkingDiagnostic: null:47 Cou
ldn't resolve reference to JvmType 'MyEMFGeneratorFragment'.]
[java] java.lang.IllegalStateException: [XtextLinkingDiagnostic: null:47 Co
uldn't resolve reference to JvmType 'MyLEMFGeneratorFragment'.]
[java] at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner
.java:88)
[java] at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner
.java:62)
[java] at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner
.java:52)
[java] at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Laun
cher.java:78)
[java] at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Lau
ncher.java:36)
[java] Java Result: 1

from inside eclipse generation work correctly
But it fails with this error while generating outside eclipse using ant

[Updated on: Thu, 03 March 2016 05:18] by Moderator

Re: I was wondering if its possible to make all my emf classes extends MyOwnEObject instead of EOBje [message #1725407 is a reply to message #1725404] Thu, 03 March 2016 05:22 Go to previous message
Eclipse UserFriend
this is a order of execution stuff.

you have to complile the fragment first, then run the workflow

(configure that in ant or move the fragment to a own project)
Previous Topic:Hovers on Keywords
Next Topic:Missing overrides in UIModule in Xtext 2.9
Goto Forum:
  


Current Time: Wed Jul 23 13:42:59 EDT 2025

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

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

Back to the top