Xtext - 无法解析对对象的引用
Xtext - Couldn't resolve reference to Object
我是 Xtext 新手,在使用简单的 Xtext 程序时遇到问题:
我的语法是这样的:
grammar org.xtext.example.domainmodel.Domainmodel with org.eclipse.xtext.common.Terminals
generate domainmodel "http://www.xtext.org/example/domainmodel/Domainmodel"
Library:
(books+=Book)*;
Book:
'Book'
isbn=ID
title=STRING
(subtitle=STRING)?
pages=INT
('sequelof' sequelof=[Book])?
('hardcover'|'softcover');
我的脚本是这样的
Book J123 "LotR1" "The Fellowship" 608 hardcover
Book J124 "LotR2" "Two Towers" 510 sequelof J123 hardcover
但是第二行的 "J123" 是红色下划线,上面写着 "Couldn't resolve reference to Book 'J123'"
其他一切正常,例如内容辅助 (Strg+Space)
也许你能帮我 :)
默认情况下,引用适用于 name
属性。 IE。您需要将语法更改为以下内容:
grammar org.xtext.example.domainmodel.Domainmodel with
org.eclipse.xtext.common.Terminals
generate domainmodel "http://www.xtext.org/example/domainmodel/Domainmodel"
Library:
(books+=Book)*;
Book:
'Book'
name=ID
title=STRING
(subtitle=STRING)?
pages=INT
('sequelof' sequelof=[Book])?
('hardcover'|'softcover');
如果您不想这样做,您可以实施 IQualifiedName
提供程序,以便它使用 isbn
属性.
计算名称
我是 Xtext 新手,在使用简单的 Xtext 程序时遇到问题:
我的语法是这样的:
grammar org.xtext.example.domainmodel.Domainmodel with org.eclipse.xtext.common.Terminals
generate domainmodel "http://www.xtext.org/example/domainmodel/Domainmodel"
Library:
(books+=Book)*;
Book:
'Book'
isbn=ID
title=STRING
(subtitle=STRING)?
pages=INT
('sequelof' sequelof=[Book])?
('hardcover'|'softcover');
我的脚本是这样的
Book J123 "LotR1" "The Fellowship" 608 hardcover
Book J124 "LotR2" "Two Towers" 510 sequelof J123 hardcover
但是第二行的 "J123" 是红色下划线,上面写着 "Couldn't resolve reference to Book 'J123'"
其他一切正常,例如内容辅助 (Strg+Space)
也许你能帮我 :)
默认情况下,引用适用于 name
属性。 IE。您需要将语法更改为以下内容:
grammar org.xtext.example.domainmodel.Domainmodel with
org.eclipse.xtext.common.Terminals
generate domainmodel "http://www.xtext.org/example/domainmodel/Domainmodel"
Library:
(books+=Book)*;
Book:
'Book'
name=ID
title=STRING
(subtitle=STRING)?
pages=INT
('sequelof' sequelof=[Book])?
('hardcover'|'softcover');
如果您不想这样做,您可以实施 IQualifiedName
提供程序,以便它使用 isbn
属性.