Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Linking and MWE2 creation
icon5.gif  Linking and MWE2 creation [message #725440] Wed, 14 September 2011 19:30 Go to next message
Edu Garcia is currently offline Edu GarciaFriend
Messages: 9
Registered: September 2011
Junior Member
Hi.

I have the same question (more or less) as the topic named How to export elements from existing languages inside the forum (I don't have enough messages to post links). I have two definition files, A.xtext & B.xtext. I also have a model (BModel) defined inside B.xtext. I want to cross reference that inside A.xtext.

I've tried doing an import of the B.xtext or BModel, but so far no luck.

My other question is:

I have the MWE2 file that the project wizard generated. I'm storing a variable with each of the file.extension and grammarURI for each xtext file I have, and duplicating the language {} section inside my Workflow.Generator. So far it works, but I wanted to know if there is a better alternative than duplicating variables and sections (like using arrays and a loop). I've seen some ArrayList that could be defined, but I don't know how to fill it or iterate over it on the MWE2 file.

Thanks a lot in advance!
Re: Linking and MWE2 creation [message #725448 is a reply to message #725440] Wed, 14 September 2011 20:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

(1) i dont know what you are doing it is a lot more easy:

grammar org.xtext.example.mydslb.MyDslB with org.eclipse.xtext.common.Terminals

generate myDslB "http://www.xtext.org/example/mydslb/MyDslB"

BModel:
	"bmodel" name=ID;


grammar org.xtext.example.mydsla.MyDslA with org.eclipse.xtext.common.Terminals

generate myDslA "http://www.xtext.org/example/mydsla/MyDslA"

import "platform:/resource/org.xtext.example.mydslb/src-gen/org/xtext/example/mydslb/MyDslB.ecore" as b

ModelA:
	"modela" name=ID "refs" refs=[b::BModel]
;


module org.xtext.example.mydsla.GenerateMyDslA

import org.eclipse.emf.mwe.utils.*
import org.eclipse.xtext.generator.*
import org.eclipse.xtext.ui.generator.*

var grammarURI = "classpath:/org/xtext/example/mydsla/MyDslA.xtext"
var file.extensions = "mydsla"
var projectName = "org.xtext.example.mydsla"
var runtimeProject = "../${projectName}"

Workflow {
    bean = StandaloneSetup {
        scanClassPath = true
        platformUri = "${runtimeProject}/.."
        registerGenModelFile = "platform:/resource/org.xtext.example.mydslb/src-gen/org/xtext/example/mydslb/MyDslB.genmodel"
    }


(2) i dont know of such a possibiity

~Christian




Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Linking and MWE2 creation [message #725457 is a reply to message #725448] Wed, 14 September 2011 20:43 Go to previous messageGo to next message
Edu Garcia is currently offline Edu GarciaFriend
Messages: 9
Registered: September 2011
Junior Member
Hi! Thanks a lot for your response!

That was exactly what I needed! (although I don't fully understand yet the second part, but this is my first test, so I'm good to go for now).

Again, thanks a lot!
Re: Linking and MWE2 creation [message #725553 is a reply to message #725457] Thu, 15 September 2011 07:09 Go to previous messageGo to next message
Edu Garcia is currently offline Edu GarciaFriend
Messages: 9
Registered: September 2011
Junior Member
I was thinking of a more specific case of this linking.

Can I do a link to a:

a) specific file inside my project (like one of my DSL files). Like "element = '/file.myDslB'", and control clicking on "/file.myDslB" will open that file
b) specific Java class inside my project (not file, not method, only class). Like "element = "com.test.MySuperClass", and control clicking on "com.test.MySuperClass" will open that Java class.

The second case I think is managed in the UML example of the post I've mentioned (so maybe I need to do another two plugins to handle the interaction) but maybe I'm wrong. Is this also the case for the first option? Do I also need two plugins for each of my own DSL's I want to link from my other DSL's?

Thanks in advance!
Re: Linking and MWE2 creation [message #725735 is a reply to message #725553] Thu, 15 September 2011 16:11 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

(1) you can do this using a trick: use your iqualifiednameprovidr of b to give the root element of the bdsl the name of its resource (=file.myDslB) and have a reference like 'element' '=' ref=[b::RootOfB] and it will work out of the box
(2) read the docs on using jvmtypes => it will work out of the box

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Linking and MWE2 creation [message #725740 is a reply to message #725735] Thu, 15 September 2011 16:17 Go to previous message
Edu Garcia is currently offline Edu GarciaFriend
Messages: 9
Registered: September 2011
Junior Member
Thanks again for your kind response, Christian.

(1) Thanks for the great trick! I'm starting right now to try this, I'll let you (or better any future reader, of course) know how it goes.
(2) I was checking that just right now. I found a link to the XText documentation about jvmTypes that I think it's just what I need.
Previous Topic:Using Xtend2 in a non-xtext project
Next Topic:lexer of Xtext (antlr)
Goto Forum:
  


Current Time: Fri Apr 26 09:09:51 GMT 2024

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

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

Back to the top