Xtext - scoping in different files -


i'm not quite sure understand how scoping process works in xtext, working several model files. referencing within 1 file works fine, having specify rule along lines of ref=[referencedobject | id], can auto completion work out of box ; however, can't seem access eobject in file. information found not explicit case, , don't understand supposed make work...

i tried referencing qualifiedname, don't i'm supposed make reference happen - how separate files can access each other.

edit : code

file returns file:     uirule | eventrule ;  qualifiedname:     id ('.' id)* ;  /* first file */ uirule returns ui:     {ui}     "ui"     (screens+=screenrule (screens+=screenrule)*)? ;  screenrule returns screen:     name=id "as" "screen"     '{'         (elements+=guielementrule )*     '}' ; guielementrule returns button:     name=id "as" "element" ;   /* second file */ eventrule returns event:     {event}     "event"     rules+=rulerule* ;  rulerule returns rule:     "on" "{" on=buttonpressrule "}"     "do" "{" do=actionrule "}" ;  buttonpressrule returns pressed:     "press" "[" source=[guielement | qualifiedname] "]" ; actionrule returns open:     "open" "[" screen=[screen | qualifiedname] "]" ; 

there no difference between linking within 1 file , linking between different files: in both cases link destination lookup in index. there no distinction between these 2 cases. btw, relevant sections in manual linking , (especially) scoping.

i tried referencing qualifiedname, don't i'm supposed make reference happen - how separate files can access each other.

the relevant sections of grammar should (please note caps in referencedobject):

referencedobject:     name=id /* more stuff */;  something:     name=id ref=[referencedobject | qn];  qn:      id ('.' id)*; 

as long referencesobject has name , each of containers has name attribut should done. i'm assuming did not modify scopeprovider class of language.


edit:

the given grammar not correct , not self contained.

  • the first rule cannot datatype rule qualifiedname. grammar not compile this.

  • navigationrule not used , actionrule unknown. assume sake of example actionrule can replaced navigationrule.

  • the complete eventrule part not used. either top-level rule missing (see first point) or grammar not know how parse file event-rules. of course scoping , crossreferencing in unparsable file difficult ;-)

so: after fixing navigationrule / actionrule , using following rule first rule can generate plugins not more modification using standard "mydsl" example xtext:

file:     ui = uirule | event = eventrule ; 

then can start editor , write these 2 files (with code-completion , correct proposals in file 2):

file 1:

s1 screen {      s1e1 element      s1e2 element }  s2 screen {      s2e1 element     s2e2 element } 

file 2:

on { press [ s1.s1e1 ] } { open [ s2 ] } 

in second file crossreferences resolved: can shift-click on s2 , on s1.s1e1 , xtext jumps definition.

so if not work should start clean project or provide sscce example demonstrates problem properly.


Comments

Popular posts from this blog

javascript - JS causing window size to be bigger than necessary - Dropdown bug -

How to mention the localhost in android -

php - Calling a template part from a post -