Examples of ParsingProblem


Examples of freemarker.core.parser.ParsingProblem

    TemplateElement parent = node;
    while (parent != null && !(parent instanceof SwitchBlock) && !(parent instanceof IteratorBlock)) {
      parent = parent.getParent();
    }
    if (parent == null) {
      template.addParsingProblem(new ParsingProblem("The break directive can only be used within a loop or a switch-case construct.", node));
    }
  }
View Full Code Here

Examples of freemarker.core.parser.ParsingProblem

 
  public void visit(BodyInstruction node) {
    super.visit(node);
    Macro macro = getContainingMacro(node);
    if (macro == null) {
      template.addParsingProblem(new ParsingProblem("The nested directive can only be used inside a function or macro.", node));
    }
  }
View Full Code Here

Examples of freemarker.core.parser.ParsingProblem

    TemplateElement parent = node;
    while (parent != null && !(parent instanceof Macro)) {
      parent = parent.getParent();
    }
    if (parent == null) {
           template.addParsingProblem(new ParsingProblem("The return directive can only be used inside a function or macro.", node));
    } else {
      Macro macro = (Macro) parent;
      if (!macro.isFunction() && node.returnExp != null) {
        template.addParsingProblem(new ParsingProblem("Can only return a value from a function, not a macro", node));
      }
      else if (macro.isFunction() && node.returnExp == null) {
        template.addParsingProblem(new ParsingProblem("A function must return a value.", node));
      }
    }
  }
View Full Code Here

Examples of freemarker.core.parser.ParsingProblem

               String msg = "The variable " + key + " has already been declared in this block.";
               if (parent instanceof Macro) {
                 String macroName = ((Macro) parent).getName();
                 msg = "The variable " + key + " has already been declared in macro " + macroName + ".";
               }
               template.addParsingProblem(new ParsingProblem(msg, node));
             }
             parent.declareVariable(key);
           }
         }
  }
View Full Code Here

Examples of freemarker.core.parser.ParsingProblem

        || parent instanceof TrimBlock) {
      parent = parent.getParent();
    }
    if (!(parent instanceof UnifiedCall) && !(parent instanceof OOParamElement)) {
      String msg = "A #param directive must be directly nested in a macro invocation or in another #param directive.";
      template.addParsingProblem(new ParsingProblem(msg, node));
    } else {
      parent.declareVariable(node.getName());
    }
  }
View Full Code Here

Examples of freemarker.core.parser.ParsingProblem

    super.visit(node);
    boolean foundDefaultCase = false;
    for (TemplateNode te : node.getCases()) {
      if (((Case) te).isDefault()) {
        if (foundDefaultCase) {
          template.addParsingProblem(new ParsingProblem("You can only have one default case in a switch construct.", node));
        }
        foundDefaultCase = true;
      }
    }
  }
View Full Code Here

Examples of freemarker.core.parser.ParsingProblem

    super.visit(node);
    try {
      node.parseFormat();
    } catch (Exception e) {
      String msg = e.getMessage();
      ParsingProblem problem = new ParsingProblem(msg, node);
      template.addParsingProblem(problem);
    }
    markAsProducingOutput(node);
    checkLiteralInNumericalContext(node.getExpression());
  }
View Full Code Here

Examples of freemarker.core.parser.ParsingProblem

 
  public void visit(Dot node) {
    super.visit(node);
    TemplateModel target = node.getTarget().literalValue();
    if (target != null && !(target instanceof TemplateHashModel)) {
      template.addParsingProblem(new ParsingProblem("Expression " + node.getTarget().getSource() + " is not a hash type.", node.getTarget()));
    }
  }
View Full Code Here

Examples of freemarker.core.parser.ParsingProblem

  public void visit(DynamicKeyName node) {
    super.visit(node);
    TemplateModel target = node.getTarget().literalValue();
    if (target != null && !(target instanceof TemplateHashModel) && !(target instanceof TemplateSequenceModel)) {
      String msg = "Expression: " + node.getTarget().getSource() + " is not a hash or sequence type.";
      template.addParsingProblem(new ParsingProblem(msg, node.getTarget()));
    }
    if (!(node.getNameExpression() instanceof Range)) {
      checkLiteralInScalarContext(node.getNameExpression());
    }
  }
View Full Code Here

Examples of freemarker.core.parser.ParsingProblem

      try {
        node.checkInterpolation();
      } catch (ParseException pe) {
        String msg = "Error in string " + node.getStartLocation();
        msg += "\n" + pe.getMessage();
        template.addParsingProblem(new ParsingProblem(msg, node));
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.