Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext import problem(import from another .xtext file)
icon5.gif  Xtext import problem [message #1017127] Sat, 09 March 2013 17:14 Go to next message
Frank Schlawiner is currently offline Frank SchlawinerFriend
Messages: 1
Registered: March 2013
Junior Member
i'm using Eclipse Juno. I have 2 .xtext files (MyDsl.xtext, Form.xtext). In the MyDsl.xtext i want to describe the general structure of my .xtext document. There i also import the Form.xtext.
grammar org.xtext.example.mydsl.MyDsl with org.xtext.example.mydsl.form.Form 

generate myDsl "example/mydsl/MyDsl"

import "example/mydsl/form/Form"
	'<html>' inHtmlTag += TagInHtmlTag '</html>' 


	'<body>' tagsInBodyTag += TagInBodyTag+ '</body>'
	formTag=FormTag | H1Tag // | otherTag

In the Form.xtext i declare the elements for the MyDsl.xtext
grammar org.xtext.example.mydsl.form.Form with org.eclipse.xtext.common.Terminals

generate form "example/mydsl/form/Form"

	'<form action=' name=STRING '>' formelemente += Formelement+ '</form>'	

	Label | Textfield

In the GenerateMyDsl.mwe2 i registered the package and GenModelFile so the import should work.
Workflow {
    bean = StandaloneSetup {
            scanClassPath = true
            platformUri = "${runtimeProject}/.."
            registerGeneratedEPackage = "org.xtext.example.mydsl.form"
            registerGenModelFile = "platform:/resource/de.uniRostock.xtextProject2013.Chr_Gju_Han_Pio.DSL_IntroExample/src-gen/org/xtext/example/mydsl/form/Form.genmodel"

But if i right-click on the MyDsl.xtext to generate the xtext artifacts i get an error.
java.lang.RuntimeException: Problems instantiating module org.xtext.example.mydsl.GenerateMyDsl: java.lang.reflect.InvocationTargetException

The error says that it couldn't find the interface org.xtext.example.mydsl.form which i set in the GenerateMyDsl.mwe2 (registerGeneratedEPackage = "org.xtext.example.mydsl.form")
Caused by: org.eclipse.emf.mwe.core.ConfigurationException: Couldn't find an interface org.xtext.example.mydsl.form
	at org.eclipse.emf.mwe.utils.StandaloneSetup.addRegisterGeneratedEPackage(
	... 34 more

Has anybody an idea, what might be wrong? I tried so many things, but nothing really worked.
Re: Xtext import problem [message #1017402 is a reply to message #1017127] Mon, 11 March 2013 18:56 Go to previous messageGo to next message
Nicole BehlenFriend
Messages: 7
Registered: May 2012
Location: Madrid
Junior Member

I think the registerGeneratedEPackage should be "org.xtext.example.mydsl.form.FormPackage" or something like this?

[Updated on: Mon, 11 March 2013 19:47]

Report message to a moderator

Re: Xtext import problem [message #1017417 is a reply to message #1017402] Mon, 11 March 2013 19:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 9836
Registered: July 2009
Senior Member
Yes it is the full qualifed name of the EPackage class
Re: Xtext import problem [message #1017667 is a reply to message #1017417] Tue, 12 March 2013 09:42 Go to previous message
Michal S is currently offline Michal SFriend
Messages: 74
Registered: July 2011
I was just solving similar issue, thank you for help.
I got to the next stage - I can run MWE2 workflow without error.

The issue, which I am trying to solve now, is, that my generated is full of errors as follows:
The method getSomeElementFromFirstDslAccess() is undefined for the type MySecondDslGrammarAccess
and the "Problems" window shows:
1. The project was not built since its build path is incomplete. Cannot find the class file for$MyFirstDslContentElements. Fix the build path then try building this project.
2.$MyFirstDslContentElements cannot be resolved. It is indirectly referenced from required .class files

part of my MWE2:
bean = StandaloneSetup {
    scanClassPath = true
    platformUri = "${runtimeProject}/.."
    registerGeneratedEPackage = "myFirstProject.myFirstDsl.MyFirstDslPackage"
    registerGenModelFile = "platform:/resource/myFirstProject/src-gen/.../MyFirstDsl.genmodel"

My second grammar:
grammar mySecondProject.MySecondDsl with myFirstProject.MyFirstDsl
generate mySecondDsl ""
import "" as first

	checks += MyCheck+
	'CHECK' check = Check // Check is defined in MyFirstDsl

and I have also added dependency to first project in Required Plug-ins in MANIFEST.MF.

I guess, that I did not "export" some elements from myFirstDsl, but I am not sure and I also do not know, how to do it.

Thank you
Previous Topic:xText Builder dependency for namedspace import
Next Topic:LL(*)-left refactoring and cross-reference
Goto Forum:

Current Time: Sat Oct 22 07:08:11 GMT 2016

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

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