【问题标题】:Xtext DSL plugin only provides keyword suggestions for the first line of the fileXtext DSL 插件只为文件的第一行提供关键字建议
【发布时间】:2019-05-12 02:23:39
【问题描述】:

我一直在使用 Xtext 开发 DSL 作为 Eclipse 插件,到目前为止,我能够达到运行时 Eclipse 应用程序在按下 Ctrl+空格时提供建议列表的地步。但是,建议仅针对文件的第一行显示。之后,无论我按了多少次 Ctrl+空格,建议都不会出现。下面是我的 Xtext 语法:

Domainmodel:
    (elements+=MainElement)
;

MainElement:
    ProjectionName | ProjectionComponent | LayerSpecification |
    Description | Capability | Category | ServiceGroup |
    IncludeFragment | {MainElement} Override | {MainElement} Overtake
;

ProjectionName:
    'projection' modelName=ID ';'
;

ProjectionComponent:
    'component' componentName=ID ';'
;

LayerSpecification:
    'layer' layerName=ID ';'
;

Description:
    'description' string=STRING ';'
;

Capability:
    'capability' type=('Online' | 'Offline') ';'
;

Category:
    'category' type=('Integration' | 'ExternalB2B' | 'Users') ';'
;

ServiceGroup:
    'servicegroup' type=('Mobility' | 'Reporting') ';'
;

IncludeFragment:
    ('@Dynamic_Component_Dependency' componentName=ID) 'include' 'fragment' fragmentToIncludeName=ID ';'
;

Override:
    '@Override'
;

Overtake:
    '@Overtake'
;

我还尝试了另一个没有此问题的更简单的示例(如下所述):-

Domainmodel:    (elements+=MainElement)* ;

MainElement:    FileName | Type  ;

Type:   Component | Layer | Description | Category | Entity | Comment ;

FileName:   'projection' name=ID ';' ;

Component:  'component' name=ID ';' ;

Layer:  'layer' name=ID ';' ;

Description:    'description' string=STRING ';' ;

List:   Users | Developers ;

Users:  'Users' ;

Developers:     'Developers' ;

Category:   'category' lists=List ';' ;

Entity:     'entityset' name=ID 'for' name2=ID ';' ;

Comment:    '----------' comment=ID '----------' ;

谁能帮助我理解为什么提到的问题发生在第一个代码而不是第二个代码上?

谢谢!

【问题讨论】:

    标签: eclipse eclipse-plugin dsl xtext


    【解决方案1】:

    您的第二个语法在规则Domainmodel: (elements+=MainElement)* ; 中使用零对多基数,而您的第一个语法似乎缺少* 符号Domainmodel: (elements+=MainElement);

    将其修复为 Domainmodel: (elements+=MainElement)*; 会有所帮助。

    【讨论】:

    • 谢谢!我错过了*符号。 :-)
    猜你喜欢
    • 2013-03-05
    • 1970-01-01
    • 2013-03-15
    • 2020-11-17
    • 1970-01-01
    • 1970-01-01
    • 2021-12-04
    • 2016-11-01
    • 1970-01-01
    相关资源
    最近更新 更多