Xtext project from an existing ecore model : generation impossible [message #547792] |
Mon, 19 July 2010 15:54 |
jeremie Messages: 233 Registered: April 2010 |
Senior Member |
|
|
Hello,
I already talked about this error in an other topic. But the topic begin to be big and we talked about many errors. So i decided to create this new topic to isolate this error.
I have really no idea to solve this problem.
In fact, every time I create a project from a existing xtext project from an ecore model, I have this errors.
when I do that I can make my own language and generate this langage.
I can then write a new file (foo.myDsl for example) with ma language syntaxe. until here, no problem.
But xtext want to read read foo.myDsl, it doesn't work.
I have this exception :
Caused by: org.eclipse.emf.mwe.core.WorkflowInterruptedException: Validation problems:
1 error:
foo.myDsl - /Users/jguidoux/workspace/fr.irisa.cairn.graphAdapterDSL.generator/src/model/foo.myDsl
2: An object may not circularly contain itself
I don't see any cycle possible in my model.
I will now explain you all the manipulation I have done.
1) I create a EMF project
2) create a ecore File (fooModel.ecore)
3) create a package (fooPackage)
4) create a class (CompilationUnit)
5) add a EString attribute to this class (called packageDeclaration)
6) create a genModel file from the ecore file
7) generate the model Code
create a new xtext from this ecore file
9) mofify the xtext file : he lookd like that :
[CODE][
Model returns CompilationUnitit :
'package:' adapted_Package=EString
;
EString returns ecore::EString:
STRING | ID;
/CODE]
10) run the .mwe2 file to generate the language
11) run a new eclipse wokench and create a new file (foo.myDsl)
12) write this the the file foo.myDsl :
13) place foo.myDsl ine the model pckage of the .generator project.
14) modify the .mwe2 file of the .generator project like this :
Workflow {
component = org.eclipse.xtext.mwe.Reader {
// lookup all resources on the classpath
// useJavaClassPath = true
// or define search scope explicitly
path = modelPath
// this class will be generated by the xtext generator
register = fr.irisa.cairn.graphAdapter.LanguageStandaloneSetup {}
load = {
slot = "compilationUnits"
type = "CompilationUnit"
}
}
component = org.eclipse.xpand2.Generator {
expand = "templates::Template::main FOREACH compilationUnits"
outlet = {
path = targetDir
}
fileEncoding = fileEncoding
}
}
15) modify the MyDslStandAloneSetup class like this :
@Override
public void register(final Injector injector) {
EPackage.Registry.INSTANCE.put(FooPackage.eINSTANCE.getNsURI(),FooPackage.eINSTANCE);
}
16) modify the file Template.txt like this :
«IMPORT fooPackager»
«DEFINE main FOR CompilationUnit-»
«ENDDEFINE»
17) and finally run the .mwe2 file of the generator project. but at this time, I hace this exception :
Caused by: org.eclipse.emf.mwe.core.WorkflowInterruptedException: Validation problems:
1 error:
foo.myDsl - /Users/jguidoux/workspace/fr.irisa.cairn.graphAdapterDSL.generator/src/model/foo.myDsl
2: An object may not circularly contain itself
I have this exception since more 1 weeks. And I really don't know why. As you can see, this exemple is very simple. There are no cycle in the foo.ecore file or in the foo.myDsl file.
Am I the one to have tis exception?
I searched on internet I can see this exception no where.
Does anyone has already created an xtext project from an ecore file with xtext 1.0? if yes, did it works?
Does anyone can see my mistaks?
Is it a bug from xtext?
Sorry for this long topic. but I tried to write a topi which well explain my problem with my poor english language.
Jérémie
[Updated on: Mon, 19 July 2010 15:55] Report message to a moderator
|
|
|
Re: Xtext project from an existing ecore model : generation impossible [message #547833 is a reply to message #547792] |
Mon, 19 July 2010 17:50 |
|
Hi,
the problem is how you do the registration stuff. (somehow the EObject validator for the Package is registred twice which leads the Object to be checked twiced which leads it to be detected as circular. if this is a bug or not i cannot say. maybe one of the xtext gurus can.
So;
@Override
public void register(final Injector injector) {
EPackage.Registry.INSTANCE.put(FooPackage.eINSTANCE.getNsURI(),FooPackage.eINSTANCE);
}
is bad
module workflow.MyDslGenerator
import org.eclipse.emf.mwe.utils.*
var targetDir = "src-gen"
var fileEncoding = "Cp1252"
var modelPath = "src/model"
Workflow {
bean = StandaloneSetup {
registerGeneratedEPackage = "test.TestPackage"
}
component = org.eclipse.xtext.mwe.Reader {
// lookup all resources on the classpath
// useJavaClassPath = true
// or define search scope explicitly
path = modelPath
// this class will be generated by the xtext generator
register = org.xtext.example.mydsl.MyDslStandaloneSetup {}
load = {
slot = "tests"
type = "Test"
}
}
component = org.eclipse.xpand2.Generator {
expand = "templates::Template::main FOREACH tests"
outlet = {
path = targetDir
}
fileEncoding = fileEncoding
}
}
is better - although the editor sometime complains an error.
Regards
Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: Xtext project from an existing ecore model : generation impossible [message #547938 is a reply to message #547833] |
Tue, 20 July 2010 08:46 |
jeremie Messages: 233 Registered: April 2010 |
Senior Member |
|
|
Hi christian.
thanks for your answer. you know it is since more than one week I had this problem.
I overload the register() method .of the standAloneSetup class because in my precedent topic "failed in generation" we told me to do that.
we also told me to add that in the same method to be able to import an ecore file :
Injector ecoreInjector = Guice.createInjector(new EcoreRuntimeModule());
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFac toryMap().put( "ecore",
ecoreInjector.getInstance(IResourceServiceProvider.class));
Is si also a bad way to do?
thanks again.
Jérémie
[Updated on: Tue, 20 July 2010 08:49] Report message to a moderator
|
|
|
Re: Xtext project from an existing ecore model : generation impossible [message #547947 is a reply to message #547938] |
Tue, 20 July 2010 09:02 |
|
Hi,
yes, Sven told you to do something like in Mwe2StandaloneSetup. But this change only works with some Customization of the Validator - the Java Validator for your DSL is not allowed to validate EObject rules - therefor you have to overwrite the generated getEPackages Method (as the Mwe Validator does)
public class MyDslJavaValidator extends AbstractMyDslJavaValidator {
@Override
protected List<EPackage> getEPackages() {
List<EPackage> result = new ArrayList<EPackage>();
result.add(FooPackage.eINSTANCE);
return result;
}
}
then it works with your workflow too.
Update: BTW many of us do this support in our sparetime. so it may take a week or two if you have a complex problem to look at. if you need fast personal support feel free to buy professional support.
Regards
Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
[Updated on: Tue, 20 July 2010 09:09] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05717 seconds