Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » XText File Relying on outside EMF Models(Can XText Files rely on outside emf models)
XText File Relying on outside EMF Models [message #1795523] Mon, 24 September 2018 16:32 Go to next message
Mehmetcan Sinir is currently offline Mehmetcan SinirFriend
Messages: 55
Registered: September 2018
Member
I am developing an Xtext Grammar, which I am going to then build into a language server, with which I will build an extension for VS Code, NOT ECLIPSE.

1) Can my grammar depend on outside EMF Models (which are not generated by Xtext, they are created manually by me), and their generated code?

Let's say my EMF genmodel has an nsURI of

'http://www.bmw.de/rhmi/image'


can my XText File depend on this Ns-Uri model like so:

import 'http://www.bmw.de/rhmi/image' as image


2) Is it a problem, that the generated code for the outside EMF Models like for example Factory and ImagePackage.java files, and util and impl folders, are not in the src/main/xtext-gen?

The generated code for outside models are not inside src/main/xtext-gen folder.

For example I have my Image.ecore and Image.genmodel, the generated model code for these are not in xtext-gen folder and when I tried to register the generated EPackage in my workflow like this:
registerGeneratedEPackage = "de.bmw.rhmi.image.ImagePackage"


I get the following error:

Caused by: org.eclipse.emf.mwe.core.ConfigurationException: Couldn't find an interface de.bmw.rhmi.image.ImagePackage
	at org.eclipse.emf.mwe.utils.StandaloneSetup.addRegisterGeneratedEPackage(StandaloneSetup.java:487)
	... 34 more


Although the full qualified name is correct.

Here is my complete workflow

module de.bmw.rhmi.GenerateHmi

import org.eclipse.xtext.xtext.generator.*
import org.eclipse.xtext.xtext.generator.model.project.*
import org.eclipse.emf.mwe.utils.*

var rootPath = ".."
var projectName = "de.bmw.rhmi"
var runtimeProject = "../${projectName}"

Workflow {

	bean = StandaloneSetup {
		scanClassPath = true
		platformUri = "${rootPath}"
		registerGenModelFile = "platform:/resource/de.bmw.rhmi/model/generated/Strings.genmodel"
		registerGenModelFile = "platform:/resource/de.bmw.rhmi/model/Image.genmodel"
		registerGeneratedEPackage = "de.bmw.rhmi.strings.StringsPackage"
		registerGeneratedEPackage = "de.bmw.rhmi.image.ImagePackage"
	}

	
	component = XtextGenerator {
		configuration = {
			project = StandardProjectConfig {
				baseName = "de.bmw.rhmi"
				rootPath = rootPath
				runtimeTest = {
					enabled = true
				}
				genericIde = {
					enabled = true
				}
				mavenLayout = true
			}
			code = {
				encoding = "UTF-8"
				lineDelimiter = "\n"
				fileHeader = "/*\n * generated by Xtext \${version}\n */"
			}
		}
		
		language = StandardLanguage {
			name = "de.bmw.rhmi.Strings"
			fileExtensions = "strings"

			serializer = {
				generateStub = false
			}
			validator = {
				// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
			}
		}
		
		language = StandardLanguage {
			referencedResource = "platform:/resource/de.bmw.rhmi/src/main/java/de/bmw/rhmi/Strings.xtext"
			referencedResource = "platform:/resource/de.bmw.rhmi/model/Image.genmodel"
			name = "de.bmw.rhmi.App"
			fileExtensions = "rapp"

			serializer = {
				generateStub = false
			}
			validator = {
				// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
			}
		}
		language = StandardLanguage {
			referencedResource = "platform:/resource/de.bmw.rhmi/src/main/java/de/bmw/rhmi/Strings.xtext"
			referencedResource = "platform:/resource/de.bmw.rhmi/model/Image.genmodel"
			referencedResource = "platform:/resource/de.bmw.rhmi/src/main/java/de/bmw/rhmi/App.xtext"	
			name = "de.bmw.rhmi.Hmi"
			fileExtensions = "hmi"

			serializer = {
				generateStub = false
			}
			
			parserGenerator={
				debugGrammar=true
			}
			
			validator = {
				// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
			}
		}
	}
	
	
}

[Updated on: Mon, 24 September 2018 16:37]

Report message to a moderator

Re: XText File Relying on EMF Models [message #1795525 is a reply to message #1795523] Mon, 24 September 2018 16:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Again. Without reproducing I can always just guess with your questions.
If you package the outside stuff and put it correctly on the classpath then this will work finde without any problems
So the question is how you packaged and put the de....rhmi stuff to the classpath
Another question would be is the dsl project and the emf project the same
The third question is the classes in a source folder
The third does the problem happen on maven or from eclipse
The forth question why did you change the stuff that was working before
The fifth if you want a separate metamodel why no separate project.

The problem is Xtext is extreme powerful and flexible and you need to know what you are doing
For me answering your questions is just wild guessing


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: XText File Relying on EMF Models [message #1795526 is a reply to message #1795525] Mon, 24 September 2018 16:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
So why did you introduce the standalonesetup the the registration of the packages

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: XText File Relying on EMF Models [message #1795528 is a reply to message #1795526] Mon, 24 September 2018 17:02 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

If you need an example, you will find that all the OCL editors rely on manually specified Ecore metamodels.

You can find the OCL editors in the *xtext* plugins of http://git.eclipse.org/c/ocl/org.eclipse.ocl.git.

The build procedures are launched from http://git.eclipse.org/c/ocl/org.eclipse.ocl.git/tree/examples/org.eclipse.ocl.examples.build/.launches

Regards

Ed Willink
Re: XText File Relying on outside EMF Models [message #1795536 is a reply to message #1795523] Mon, 24 September 2018 20:52 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Quote:
1) Can my grammar depend on outside EMF Models (which are not generated by Xtext, they are created manually by me), and their generated code?

Yes it can.

Quote:
2) Is it a problem, that the generated code for the outside EMF Models like for example Factory and ImagePackage.java files, and util and impl folders, are not in the src/main/xtext-gen?

No, that's no problem. They must be found on the classpath, it is not dependend on the source path.

Quote:
I get the following error:

ImagePackage can't be found on the classpath, or its genmodel is not registered.

We can only give you pointers here, our apologies.

~Karsten
Re: XText File Relying on outside EMF Models [message #1795538 is a reply to message #1795536] Mon, 24 September 2018 22:01 Go to previous messageGo to next message
Mehmetcan Sinir is currently offline Mehmetcan SinirFriend
Messages: 55
Registered: September 2018
Member
Thank you very much for your answers.
I will look into it tomorrow, but this already makes things clearer.

@Christian
1) DSL Projekt and the EMF Project are the same, I have a single XText Project with Gradle/Maven Layout.
2) I defined two EMF Models manually inside the "model" folder, and then generated code from the genmodel files
3) The code I generated manually from the genmodels (imp, util, factory and so on) is inside the source (src/bmw/rhmi) folder
4) The code xtext generated ((also imp, util, factory and so on) )is inside src/main/xtext-gen folder, but they are in separate packages
5) I did not think I needed a second Project just because I wanted to define two EMF models

I will look into this tomorrow, if I cannot solve it by myself I will provide the code here=)
Re: XText File Relying on outside EMF Models [message #1795543 is a reply to message #1795538] Tue, 25 September 2018 05:34 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You can certainly have more than one EMF model per plugin if you really need to. You just need to make sure that the multiple genmodels do not fight over the MANIFEST.MF and plugin.xml content.

You should probably disable contributions to MANIFEST.MF by setting the genmodel Bundle Manifest options false.

The plugin.xml contributions should have distinct Plugin Key options and so be orthogonal.

(The GIT\org.eclipse.qvtd\tests\org.eclipse.qvtd.xtext.qvtcore.tests plugin has five generated EMF models. Plugin Key is set to blank to suppress plugin.xml contributions since the test models are not wanted in a launched Eclipse workspace. The EMF genmodel activity is launched from GIT\org.eclipse.qvtd\releng\org.eclipse.qvtd.build\.launches\Generate QVTd Test Models.launch)

If you have multiple generator technologies, you may prefer to put EMF-generated content in an emf-gen rather than xtend-gen source folder to avoid confusion during manual browsing and build clean-ups. You should consider that emf-gen but not xtend-gen content is put under CM control.

Regards

Ed Willink
Re: XText File Relying on outside EMF Models [message #1795547 is a reply to message #1795543] Tue, 25 September 2018 07:29 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
you cannot use registerEPackage if you dont have class files only.
this is why you need to move the stuff either to a separate module/bundle
or have to use registerGenModelFile only


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Internal...Parser.java no such file or directory error
Next Topic:Given a ANTLRv3 grammar how to create xtext grammar
Goto Forum:
  


Current Time: Fri Mar 29 07:33:44 GMT 2024

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

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

Back to the top