Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Is it possible to define built-in EObjects
Is it possible to define built-in EObjects [message #846677] Mon, 16 April 2012 16:06 Go to next message
Daniel Le Berre is currently offline Daniel Le BerreFriend
Messages: 82
Registered: July 2009
Hi all,

We face a problem to properly manage predefined functions (native functions) in our Xtext based language.

Suppose that we have an EObject subclass A.

We would like to declare in our grammar (or in our Java code) some predefined instances of A, that have a specific name (native/a1 and native/a2 for instance).

If I declare A that way:

A :
name=(Name | "native/a1" | "native/a2")

Then the built in functions are properly recognized but as simple keywords, not as an instance of A.

Is there a way to prepopulate A with two instances corresponding to those built in functions?

Re: Is it possible to define built-in EObjects [message #857741 is a reply to message #846677] Thu, 26 April 2012 20:32 Go to previous message
Joey Mink is currently offline Joey MinkFriend
Messages: 87
Registered: July 2009
Location: Centreville, VA, USA

You can define built-in objects in your DSL language - place them in a file in your plug-in and make sure you include those files in Then bind your own IGlobalScopeProvider:

public class DSLRuntimeModule extends AbstractDSLRuntimeModule {
    public Class<? extends IGlobalScopeProvider> bindIGlobalScopeProvider() {
    	return DSLImportUriGlobalScopeProvider.class;

And make it look something like this:

public class DSLImportUriGlobalScopeProvider extends
		ImportUriGlobalScopeProvider {

	protected LinkedHashSet<URI> getImportedUris(final Resource resource) {
		LinkedHashSet<URI> temp = super.getImportedUris(resource);
		temp.add(URI.createURI("platform:/plugin/<plugin id>/resources/"));
		temp.add(URI.createURI("platform:/plugin/<plugin id>/resources/"));
		return temp;

This worked wonderfully for us, but now we're using Namespaces scoping (which I believe is the default) and I'm trying to find out how to do it without this URI approach...
Previous Topic:new xtext
Next Topic:[Solved] XbaseHoverDocumentationProvider
Goto Forum:

Current Time: Wed Jul 08 02:46:53 GMT 2020

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

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

Back to the top