I have an Xtext grammar that does something like this:
Model:
(names += Name)*
(rules += Rule)*
;
Rule:
'rule' ruleName = ID;
Name:
name = ID+;
terminal ID:
('a'..'z')+;
I want to validate the ruleName has been declared in the names block. I can access the rule name itself in the JavaValidator like this:
@Check
public void checkName(Rule rule) {
rule.getName(); // how to compare to names without access to Model object?
}
but I cannot access the names field from Model. How do I do that in the JavaValidator?
alternatively
(Model)rule.eContainer()should give you the model