0

Suppose I have a grammar "A" which cross references from another grammar "B". for example:-

test.mydsl->

entity A{
    var p;
    var q;
}

otherTest.mydsl1

entity B{
        var "??"
    }

so right now what is happening is as i press Ctrl + Space in "??" of above code piece, it shows A.p and A.q in content assist but i dont want that i just want it to show "p" or "q" in content assist. Is there some example from which i can refer where content assist just shows options with simple name and not FQN ?

  • then you need either to create an (implicit import to A.* - but why A.* and not C.*) or you need to change the indexing (IQualifiedNameProvider) to index stuff as p and q and not A.p. but again wht if there is enitiy C with p and q – Christian Dietrich Jun 03 '21 at 09:47
  • thanks, I used implicit import and it is working, however in content assist(Ctrl + Space) it is still showing as A.p and as i enter it puts just "p". Is there some way that i can alter content assist so that i can see just "p" and not A.p. – Siddhant Gupta Jun 03 '21 at 12:37
  • if there are multiple entities with same var then it will give an error, however it will not be possible since what i am trying to achieve is just create one file of ".mydsl" to create variables and use them in all the files of ".mydsl1". hope it makes sense. – Siddhant Gupta Jun 03 '21 at 12:39
  • then simply adating the IQualifiedNameProvider in mydsl (subclass DefaultDeclarativeQualifiedNameProvider) should do the trick. see https://dietrich-it.de/xtext/2011/07/16/iqualifiednameproviders-in-xtext-2.0/ – Christian Dietrich Jun 03 '21 at 12:44
  • for labels check MyDslDescriptionLabelProvider – Christian Dietrich Jun 03 '21 at 12:45

0 Answers0