Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Problem using xreference
Problem using xreference [message #1723082] Thu, 11 February 2016 13:22 Go to next message
Mirko Dohrendorf is currently offline Mirko DohrendorfFriend
Messages: 2
Registered: February 2016
Junior Member
Dear All,
I've got this small grammar here:
Model:
facts+=Fact*;

Fact:
	Enumerat|Pred
;

Enumerat:
name=ID'+' (':=' '{' elements+=EnmElm (',' elements+=EnmElm)* '}')?;

EnmElm:
name=ID;

Pred: 
'Is' test=[Enumerat] '==' elem=[EnmElm] '?';

I've tested this with this input:
Enum+ := {one,two}

Is Enum == one ?


But then i got an error, saying "Couldn't resolve reference to EnmElm 'one'."
So what i need is referencing elements of an Enumerats elements list. But is this possible?

best regards,
Mirko


Re: Problem using xreference [message #1723121 is a reply to message #1723082] Thu, 11 February 2016 20:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
Hi,

you have to implement the scopeprovider. in xtext 2.9 this could look like (pseudo code)

    override getScope(EObject context, EReference reference) {
        // We want to define the Scope for the Element's superElement cross-reference
        if (context instanceof Pred
                && reference == MyDslPackage.Literals.PRED__ELEM) {
            // ask the pred from its test and the test for its elements
            val candidates = (context as Pred).test.elements
            return Scopes.scopeFor(candidates)
        }
        return super.getScope(context, reference);
    }


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problem using xreference [message #1723189 is a reply to message #1723121] Fri, 12 February 2016 12:35 Go to previous message
Mirko Dohrendorf is currently offline Mirko DohrendorfFriend
Messages: 2
Registered: February 2016
Junior Member
Christian,
Thank you very much for the quick response. I aleady tried to implement the scopeProvider before but i made a mistake at the referencetype selection. But now with your help it works fine Smile
Previous Topic:Regarding Resource URI
Next Topic:book still uptodate?
Goto Forum:
  


Current Time: Wed Sep 22 00:44:01 GMT 2021

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

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

Back to the top