我有一个 Xtext 语法,它做这样的事情:
Model:
(names += Name)*
(rules += Rule)*
;
Rule:
'rule' ruleName = ID;
Name:
name = ID+;
terminal ID:
('a'..'z')+;
我想验证ruleName
已在名称块中声明。我可以像这样访问规则名称本身JavaValidator
:
@Check
public void checkName(Rule rule) {
rule.getName(); // how to compare to names without access to Model object?
}
但我无法names
从Model
. 我该怎么做JavaValidator
?