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 12:14 Go to next message
Frank Schlawiner is currently offline Frank Schlawiner
Messages: 1
Registered: March 2013
Junior Member
Hi,
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"
	
HtmlTag:
	'<html>' inHtmlTag += TagInHtmlTag '</html>' 
;

...

BodyTag:
	'<body>' tagsInBodyTag += TagInBodyTag+ '</body>'
;
TagInBodyTag:
	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"

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

Formelement:
	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
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:95)

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(StandaloneSetup.java:309)
	... 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 14:56 Go to previous messageGo to next message
Nicole Behlen
Messages: 6
Registered: May 2012
Location: Madrid
Junior Member
Hi,

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

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

Report message to a moderator

Re: Xtext import problem [message #1017417 is a reply to message #1017402] Mon, 11 March 2013 15:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 5849
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 05:42 Go to previous message
Michal S is currently offline Michal S
Messages: 73
Registered: July 2011
Member
Hello,
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 InternalMySecondDslParser.java 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 myFirstProject.services.MyFirstDslGrammarAccess$MyFirstDslContentElements. Fix the build path then try building this project.
2. myFirstProject.services.MyFirstDslGrammarAccess$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 "http://www.dsl.my/mySecondDsl/MySecondDsl"
import "http://www.dsl.my/myFirstDsl/MyFirstDsl" as first

Model:
	checks += MyCheck+
;
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
Michal
Previous Topic:xText Builder dependency for namedspace import
Next Topic:LL(*)-left refactoring and cross-reference
Goto Forum:
  


Current Time: Sun Apr 20 18:02:53 EDT 2014

Powered by FUDForum. Page generated in 0.01545 seconds