Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to avoid including ecore for dsl and load dynamically using Namespace uri of the ecore ?
How to avoid including ecore for dsl and load dynamically using Namespace uri of the ecore ? [message #1017197] Mon, 11 March 2013 04:15 Go to next message
Sri MV is currently offline Sri MVFriend
Messages: 12
Registered: February 2013
Junior Member
Hi,


I am new to xtext and trying to explore xtext . I have included my grammar and scope provider thanks to christian , Everytime i need to explicitly include my ecore within the project . Is there way in which i could load the ecore Eclass contents dynamically using Name spcae uri of the ecore.


Model:
	"EClass:" theEClass=[ecore::EClass|FQN] "Feature:" theFeature=[ecore::EStructuralFeature];	
FQN: ID("." ID)*;



public class MyDslscopeProvider extends AbstractDeclarativescopeProvider {
	
	public Iscope scope_Model_theFeature(Model model, EReference ref) {
		return scopes.scopeFor(model.getTheEClass().getEAllStructuralFeatures());
	}

}



For the above grammar text dsl project will look similar like this

 TestProject

    |- my.dsl

    |- sample.ecore



Everytime i need to include sample.ecore to show up classes in my project .. Is there way i could dynamically load and avoid adding sample.ecore everytime.


Regards,
Sri

[Updated on: Mon, 11 March 2013 04:16]

Report message to a moderator

Re: How to avoid including ecore for dsl and load dynamically using Namespace uri of the ecore ? [message #1017209 is a reply to message #1017197] Mon, 11 March 2013 07:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6485
Registered: July 2009
Senior Member
Hi I guess some basic reading on ecore could help. There is a
EPackage.Registry (but of course the package has to be registered
there. But same as in the other thread. I don't know your usecase so
hard to say anything

--
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: How to avoid including ecore for dsl and load dynamically using Namespace uri of the ecore ? [message #1017215 is a reply to message #1017209] Mon, 11 March 2013 08:19 Go to previous messageGo to next message
Sri MV is currently offline Sri MVFriend
Messages: 12
Registered: February 2013
Junior Member
Hi Christian ,

My use case is very simple .

I am trying to create a simple editor for configuring a name rule which is a String made of EClass and EStructural feature of the ecore . I will not be generating any Java code from my grammar.

Does xtext provide content assist support for external ecore where i can get the EClass name and EStructural name for my name rule configuration.

Please refer the below model

http://i.stack.imgur.com/Qz4td.png


Simple content assist for Apple.name as my rule configurator


Regards,
Sri M.V

[Updated on: Mon, 11 March 2013 08:21]

Report message to a moderator

Re: How to avoid including ecore for dsl and load dynamically using Namespace uri of the ecore ? [message #1017241 is a reply to message #1017215] Mon, 11 March 2013 09:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6485
Registered: July 2009
Senior Member
Hi,

what xtext does when you drop the ecore: the ecore is read as model und put into the Xtext index and thus is
referenceable from the .mydsl file.

SO if you dont want to drop the .ecore file what is the criteria to find it?
when is the ecore file created. and how should it be updated?
where should xtext look for it?

btw i was talking about the java code for the ecore.
Re: How to avoid including ecore for dsl and load dynamically using Namespace uri of the ecore ? [message #1017249 is a reply to message #1017241] Mon, 11 March 2013 10:01 Go to previous messageGo to next message
Sri MV is currently offline Sri MVFriend
Messages: 12
Registered: February 2013
Junior Member
Hi Christian ,


Ecore would be part of my target . Is there a way where i can get from the target and Xtext index the target ecore .


Regards,
Sri M.V
Re: How to avoid including ecore for dsl and load dynamically using Namespace uri of the ecore ? [message #1017250 is a reply to message #1017249] Mon, 11 March 2013 10:10 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6485
Registered: July 2009
Senior Member
Only if the Model project is a java Project.
Or you do the scoping yourself
(load the ecore reflective or via its java package)

=> write a scope method for the class too (scope_Model_theEClass)
Previous Topic:importURI and cross references during serialization
Next Topic:dependency injection in Xtext source code
Goto Forum:
  


Current Time: Sun Nov 23 18:51:34 GMT 2014

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

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