Xtext Content assist configuration

I want that the content assist suggests the name of variables already declared in the script. this is the grammar:

Script:
    includes+=(Include)* assignments+=(Assignment)* g=GetLog?  clock=Clock? tests+=Test*
;

Include:
    'INCLUDE' includedScript=[Script|STRING]
;

Test:
    'RUN'  "(" name=STRING "," com=STRING "," association=STRING ")" '{' instructions+=Instruction* '}'
;

Instruction:
    Set |
    Get |
    Verify |
    Execute |
    Wait |
    Print |
    Time |
    SetTime |
    PowerDown |
    PowerUp |
    GetIp |
    GetLog




Set:
    'SET' '(' attribute=AttributeRef ',' value=(AttributeValue ) ')'
;

Get : 

    'GET' '(' attribute=AttributeRef ')'
;
AttributeRef:
    cosem=IDValue "." attributeRef =IDValue

;

the cosem in AttributeRef part is wich has to be already declared before.

for example, in this script when taping Tariffication the content assist shows TarifficationScriptTable

TarifficationScriptTable = COSEM(9,0,"0.0.10.0.100.255")



RUN("CheckConnectivity", "HDLC", "LOCAL_MANAGEMENT") {  

GET(Tariffi

Answer

this is what cross references are made for. you use them for scripts already. they look like

nameOfTheReference=[TypeYouWantToReference]

which is actually is a short for for

nameOfTheReference=[TypeYouWantToReference|ID]

which means “reference a TypeYouWantToReferenceand parse an ID”

if you have another rule that should be parsed you may use

nameOfTheReference=[TypeYouWantToReference|OtherRULE]

Leave a Reply

Your email address will not be published. Required fields are marked *