java - Xtext 内容辅助配置

标签 java dsl xtext xtend

我希望内容辅助建议脚本中已声明的变量的名称。这是语法:

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

;

cosemAttributeRef部分是之前必须已经声明的部分。

例如,在此脚本中,当点击 Tariffication 时,内容辅助会显示 TarifficationScriptTable

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



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

GET(Tariffi

最佳答案

这就是交叉引用的目的。您已经将它们用于脚本了。他们看起来像

nameOfTheReference=[TypeYouWantToReference]

这实际上是 for 的缩写

nameOfTheReference=[TypeYouWantToReference|ID]

这意味着“引用 TypeYouWantToReference 并解析 ID”

如果您有其他需要解析的规则,您可以使用

nameOfTheReference=[TypeYouWantToReference|OtherRULE]

关于java - Xtext 内容辅助配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41765013/

相关文章:

java - 从 org.eclipse.xtext.common.types 获取 "new"依赖项

java - 无法在主线程上访问数据库,因为它可能会长时间锁定 UI

java - Spring Beans 的公共(public)访问修饰符和模块导出

java - SOAP 客户端端口困惑

java - 验证用户输入

Xtext 自定义交叉引用

java - Java 中的列表转换接口(interface)失败

c++ - 在 C++ 项目中使用特定领域的语言文件

tomcat - docker tomcat重新部署应用程序

macros - 将 Clojure 宏用于 DSL