Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 09:50 Go to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
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 09:55]

Report message to a 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 10:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
hi which xtext version do you use?

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 10:02 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 83
Registered: January 2016
Location: Kiel
Member

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 10:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
@Sven couldnt one subclass EmfGeneratorFragment(2) and override getGenModel
and set the genmodels rootExtendsClass


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 10:29 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 83
Registered: January 2016
Location: Kiel
Member

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 10:49 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
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 11:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
kimi raikonnan <forums-noreply@xxxxxxxx> wrote:
> I am using version 2.8
>

Then you can try the subclass emfgeneratorfragment Approach


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 12:07 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
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 12:08]

Report message to a 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 12:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
hi you have to override getTemplate as well and return
EMFGeneratorFragment.class.getName().....

instead of

getClass().getName() .....


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 12:43 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
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 12:43]

Report message to a 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 12:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
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?


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 13:13 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
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 13:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
sry have no idea on that, maybe a question for the emf forum.

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 14:48 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
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 14:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
yes it is. but i dont know how to solve it, what is you please the class in a package that fits?

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 14:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
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 {
}


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 15:40 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
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 15:46 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
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


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 10:17 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
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 10:18]

Report message to a 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 10:22 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
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)


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Hovers on Keywords
Next Topic:Missing overrides in UIModule in Xtext 2.9
Goto Forum:
  


Current Time: Sat Sep 18 02:02:01 GMT 2021

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

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

Back to the top