Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Xtext project from an existing ecore model : generation impossible( An object may not circularly contain itself)
Xtext project from an existing ecore model : generation impossible [message #547792] Mon, 19 July 2010 11:54 Go to next message
Eclipse UserFriend
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
Cool 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 :
package foo


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 11:55] by Moderator

Re: Xtext project from an existing ecore model : generation impossible [message #547833 is a reply to message #547792] Mon, 19 July 2010 13:50 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Xtext project from an existing ecore model : generation impossible [message #547938 is a reply to message #547833] Tue, 20 July 2010 04:46 Go to previous messageGo to next message
Eclipse UserFriend
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 04:49] by Moderator

Re: Xtext project from an existing ecore model : generation impossible [message #547947 is a reply to message #547938] Tue, 20 July 2010 05:02 Go to previous messageGo to next message
Eclipse UserFriend
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

[Updated on: Tue, 20 July 2010 05:09] by Moderator

Re: Xtext project from an existing ecore model : generation impossible [message #547975 is a reply to message #547947] Tue, 20 July 2010 06:09 Go to previous messageGo to next message
Eclipse UserFriend
I prefere to add the line in the workflow.
less line to modify ^^.

But really thanks. I have the impression as everything works well Smile.

No I can work with Xpand/Xtend.

thanks a lot Smile


Jeremie
Re: Xtext project from an existing ecore model : generation impossible [message #659832 is a reply to message #547975] Tue, 15 March 2011 14:19 Go to previous messageGo to next message
Eclipse UserFriend
It seems that you have some emf validation plugin for your ecore metamodel, right?

I faced the same problem, and I only put to false the following property in the java validator fragment:
fragment = validation.JavaValidatorFragment {
	registerForImportedPackages = false
}


Now it seems that Xtext don't try to register my emf validator which is already registered by its own plugin. Right?

It seems to fit my need, but is it ok to do it like this?



Re: Xtext project from an existing ecore model : generation impossible [message #659841 is a reply to message #659832] Tue, 15 March 2011 14:48 Go to previous message
Eclipse UserFriend
Hi,

yes this seems to be a proper solution.

~Christian
Previous Topic:get name of referenced object when there is an error
Next Topic:Unresolved cross references
Goto Forum:
  


Current Time: Mon Jul 07 21:52:22 EDT 2025

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

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

Back to the top