Skip to main content


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
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.
  • Attachment: Form.xtext
    (Size: 0.41KB, Downloaded 146 times)
  • Attachment: GenerateMyDsl.mwe2
    (Size: 5.80KB, Downloaded 173 times)
  • Attachment: MyDsl.xtext
    (Size: 0.80KB, Downloaded 173 times)
  • Attachment: MANIFEST.MF
    (Size: 1.66KB, Downloaded 257 times)
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: 8
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 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: 14665
Registered: July 2009
Senior Member
Yes it is the full qualifed name of the EPackage class

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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
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: Thu Apr 25 12:36:14 GMT 2024

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

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

Back to the top