Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » xtend: How to import resources of resource
xtend: How to import resources of resource [message #932944] Thu, 04 October 2012 15:40 Go to next message
Li K. is currently offline Li K.Friend
Messages: 9
Registered: September 2012
Junior Member
Hi all,

I've got a modelA, which is an instance of mm1.ecore.
I've got a modelB written in mydsl, which is defined with xtext using another metamodel mm2. This modelB imports modelA. Till here everything works perfectly.

Now I'm trying to generate code for modelB using xtend. But when I hit 'run as MWE2 workflow' on my mwe2 file in order to generate code I'm getting the error 'Imported resource could not be found.'

So I am wondering whether I can import the resources that are used in my modelB? Or is there a better way to solve this problem?

Thanks heaps in advance!!
Re: xtend: How to import resources of resource [message #933197 is a reply to message #932944] Thu, 04 October 2012 20:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6499
Registered: July 2009
Senior Member
Hi,

i am not quite sure what you mean with "modelB imports modelA"
can you please elaborate

~Christian
Re: xtend: How to import resources of resource [message #933799 is a reply to message #933197] Fri, 05 October 2012 10:58 Go to previous messageGo to next message
Li K. is currently offline Li K.Friend
Messages: 9
Registered: September 2012
Junior Member
My modelB looks like this:

import modelA

testcase SingleLeafDoor  {

[...]

}


Whereas modelA is an model for an ecore model and consists of different kind of doors (SingleLeafDoor, DoubleLeafDoor,...)

And the error messages when hitting the xtend workflow say:
243  ERROR Mwe2Launcher  - Problems running workflow de.android.workflow.GenerateAndroidTests: Validation problems: 
2 errors:
modelB.test - C:\workspace\de.android\.\..\de.models\model\modelB.test
1: Imported resource could not be found.
3: Couldn't resolve reference to Door 'SingleLeafDoor'.


I hope this helped to understand the problem.

Thank you once again!!


edit: 'modelA' in the import statement 'import modelA' is an URI

[Updated on: Fri, 05 October 2012 11:00]

Report message to a moderator

Re: xtend: How to import resources of resource [message #933810 is a reply to message #933799] Fri, 05 October 2012 11:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6499
Registered: July 2009
Senior Member
Can you please post your grammar?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: xtend: How to import resources of resource [message #935171 is a reply to message #933810] Sat, 06 October 2012 19:21 Go to previous messageGo to next message
Li K. is currently offline Li K.Friend
Messages: 9
Registered: September 2012
Junior Member
I do not think that the grammar is the problem, since my dsl works fine (It resolves all imported URIs in the eclipse application and also recognises the elements within the imported resources).
It's xtend where I got (and I am still) stuck. Here is the grammar, though. For better understanding I reduced it to the lines which are used in the example above:
grammar de.test.Language with org.eclipse.xtext.common.Terminals hidden(WS)

import "platform:/resource/de.metamodel/model/house.ecore" as house
import "platform:/resource/de.test.metamodel/model/house-test.ecore" as test 
import "http://www.eclipse.org/emf/2002/Ecore" as ecore

UITest returns test::UITest:
	(importDeclarations += ImportDeclaration)*
	'testcase' (door = [house::Door]) '{'
		(statements += Statement)+
	'}'	
;

ImportDeclaration returns test::ImportDeclaration:
	'import' importURI=STRING 
;

Statement returns test::Statement:
	[...]
;
Re: xtend: How to import resources of resource [message #935185 is a reply to message #935171] Sat, 06 October 2012 19:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6499
Registered: July 2009
Senior Member
Hi,

did you write a resourceserviceprovider for that? you have to write and use a org.eclipse.xtext.resource.generic.AbstractGenericResourceSupport too
see http://christiandietrich.wordpress.com/2011/07/17/xtext-2-0-and-uml/

~Christian
Re: xtend: How to import resources of resource [message #935820 is a reply to message #935185] Sun, 07 October 2012 10:55 Go to previous messageGo to next message
Li K. is currently offline Li K.Friend
Messages: 9
Registered: September 2012
Junior Member
Hello again,

do I have to write an custom resourceserviceprovider even though both my metamodels are ecore models?
I added 2 plugin dependencies (org.eclipse.xtext.ecore and org.eclipse.xtext.ui.ecore) to the language project and an extension point for the resourceServiceProvider in my language ui project (de.test.ui).

Should I do something like that in my xtend project, as well? I could not find a plugin.mxl file in this project. Thus I do not know where I could put an extension point there?
Re: xtend: How to import resources of resource [message #935829 is a reply to message #935820] Sun, 07 October 2012 11:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6499
Registered: July 2009
Senior Member
Hi,

i still do not get what you are doing. is your stuff working in the ui or is it not? xtext by default only allows to reference stuff that is exposed through a resourceserviceprovider.
this is done by the org.eclipse.xtext.ecore plugin for .ecore files and for all xtext grammars.

so if you have a xzy.ecore and a .xyz file and .xyz is not read with xtext but with a std ecore editor then you will need a custom resourceserviceprovider.

so of what kind is your house stuff??????

~Christian
Re: xtend: How to import resources of resource [message #935888 is a reply to message #935829] Sun, 07 October 2012 12:33 Go to previous messageGo to next message
Li K. is currently offline Li K.Friend
Messages: 9
Registered: September 2012
Junior Member
Hi,

my house stuff is a .ecore file and my language works in the ui. So I've created an model:

import modelA

testcase SingleLeafDoor  {

[...]

}


This works (imports and resolves the resources).

But now I need java code from this model, so I am using xtend to generate this java code and here is the clue: Now it complains and says:

243  ERROR Mwe2Launcher  - Problems running workflow de.android.workflow.GenerateAndroidTests: Validation problems: 
2 errors:
modelB.test - C:\workspace\de.android\.\..\de.models\model\modelB.test
1: Imported resource could not be found.
3: Couldn't resolve reference to Door 'SingleLeafDoor'.
Re: xtend: How to import resources of resource [message #935915 is a reply to message #935888] Sun, 07 October 2012 13:11 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6499
Registered: July 2009
Senior Member
Hi,

can you share a complete reproduceable example?

~Christian
Re: xtend: How to import resources of resource [message #937057 is a reply to message #935915] Mon, 08 October 2012 16:11 Go to previous message
Li K. is currently offline Li K.Friend
Messages: 9
Registered: September 2012
Junior Member
Hi,

I've noticed that I'm using the approach 'xtend 2 code generators with non xtext models' for the dsl.
Now I see where was the problem to understand my explanation. I am sorry for that!! Nevertheless I am grateful for your help.
I try to use the approach of the statemachine example with the integrated xtend. I hope this will work.

Regards
Previous Topic:Formatting nested if expression in switch expression fails
Next Topic:Adding Perspective to Xtext
Goto Forum:
  


Current Time: Sat Nov 29 10:18:56 GMT 2014

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

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