use of net.vtst.ow.eclipse.soy.soy.PrintDirectiveDeclaration in project ow by vtst.
the class SoyJavaValidator method checkPrintDirective.
// **************************************************************************
// Print directives
/**
* Check:
* - There is no whitespace after the '|' in print directives,
* - The directive name is known,
* - The directive has the right number of parameters.
*/
@Check
public void checkPrintDirective(PrintDirective printDirective) {
// Check there is no whitespace after the '|'
ICompositeNode parserNode = NodeModelUtils.getNode(printDirective);
for (INode node : parserNode.getChildren()) {
EObject grammarElement = node.getGrammarElement();
if (grammarElement instanceof Keyword) {
String keywordValue = ((Keyword) grammarElement).getValue();
if ("|".equals(keywordValue)) {
if (node.getNextSibling() instanceof HiddenLeafNode) {
error(messages.getString("print_directive_whitespace_after_pipe"), printDirective, SoyPackage.eINSTANCE.getPrintDirective_Ident(), 0);
}
} else if (":".equals(keywordValue)) {
if (node.getNextSibling() instanceof HiddenLeafNode) {
error(messages.getString("print_directive_whitespace_before_colon"), printDirective, SoyPackage.eINSTANCE.getPrintDirective_Ident(), 0);
}
}
}
}
PrintDirectiveDeclaration printDirectiveDeclaration = printDirective.getIdent();
// Do not validate unlinked elements
if (printDirectiveDeclaration.getIdent() == null)
return;
doCheckNumberOfArguments(printDirective.getParameter().size(), printDirectiveDeclaration.getNumber_of_required_arguments(), printDirectiveDeclaration.getNumber_of_optional_arguments(), printDirectiveDeclaration.getIdent(), "print_directive_parameters", "print_directive_parameters_opt", printDirective, SoyPackage.eINSTANCE.getPrintDirective_Ident(), 0);
}
Aggregations