Xtext DSL插件只为文件的第一行提供关键字建议



我一直在使用Xtext开发DSL作为eclipse插件,到目前为止,我已经能够达到运行时eclipse应用程序在按下Ctrl+space时提供建议列表的地步。但是,建议仅显示在文件的第一行。之后,无论我按了多少次Ctrl+space,建议都不会来。下面是我的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 '----------' ;

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

谢谢!

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

将其固定到Domainmodel: (elements+=MainElement)*;将有所帮助。

最新更新