Examples of ParsingProblem


Examples of freemarker.core.parser.ParsingProblem

        else if (key.equals("strict_vars")) {
          boolean strictVariableDeclaration = header.getBooleanParameter("strict_vars");
                  template.setStrictVariableDeclaration(strictVariableDeclaration);
                }
        else if (!key.equals("strip_text") && !key.equals("encoding")) {
          ParsingProblem problem  = new ParsingProblem("Unknown ftl header parameter: " + entry.getKey(), header);
          template.addParsingProblem(problem);
        }
      } catch (Exception e) {
        ParsingProblem problem = new ParsingProblem(e.getMessage(), header);
        template.addParsingProblem(problem);
      }
    }
  }
View Full Code Here

Examples of freemarker.core.parser.ParsingProblem

    }
  }
 
  public void visit(Include node) {
    if (template.strictVariableDeclaration() && !node.useFreshNamespace()) {
      ParsingProblem problem = new ParsingProblem("The legacy #include instruction is not permitted in strict_vars mode. Use #embed or possibly #import.", node);
      template.addParsingProblem(problem);
    }
    super.visit(node);
  }
View Full Code Here

Examples of freemarker.core.parser.ParsingProblem

    }
    super.visit(node);
  }
 
  public void visit(InvalidExpression node) {
    template.addParsingProblem(new ParsingProblem(node.getMessage() + " " + node.getSource(), node));
  }
View Full Code Here

Examples of freemarker.core.parser.ParsingProblem

  public void visit(InvalidExpression node) {
    template.addParsingProblem(new ParsingProblem(node.getMessage() + " " + node.getSource(), node));
  }
 
  public void visit(UnclosedElement node) {
    template.addParsingProblem(new ParsingProblem(node.getDescription(), node));
  }
View Full Code Here

Examples of freemarker.core.parser.ParsingProblem

 
  public void visit(AssignmentInstruction node) {
    super.visit(node);
    if (template.strictVariableDeclaration()) {
      if (node.getType() == AssignmentInstruction.NAMESPACE) {
        ParsingProblem problem = new ParsingProblem("The assign directive is deprecated and cannot be used in strict_vars mode. See the var and set directives.", node);
        template.addParsingProblem(problem);
      }
      if (node.getType() == AssignmentInstruction.LOCAL) {
        ParsingProblem problem = new ParsingProblem("The local directive is deprecated and cannot be used in strict_vars mode. See the var and set directives.", node);
        template.addParsingProblem(problem);
      }
    }
        if (node.getType() == AssignmentInstruction.LOCAL) {
          Macro macro = getContainingMacro(node);
          if (macro == null) {
            ParsingProblem problem = new ParsingProblem("The local directive can only be used inside a function or macro.", node);
            template.addParsingProblem(problem);
          }
          else for (String varname : node.getVarNames()) {
            if (!macro.declaresVariable(varname)) {
               macro.declareVariable(varname);
View Full Code Here

Examples of freemarker.core.parser.ParsingProblem

 
  public void visit(BlockAssignment node) {
    super.visit(node);
    if (template.strictVariableDeclaration()) {
      if (node.getType() == AssignmentInstruction.NAMESPACE) {
        ParsingProblem problem = new ParsingProblem("The assign directive is deprecated and cannot be used in strict_vars mode. See the var and set directives.", node);
        template.addParsingProblem(problem);
      }
      if (node.getType() == AssignmentInstruction.LOCAL) {
        ParsingProblem problem = new ParsingProblem("The local directive is deprecated and cannot be used in strict_vars mode. See the var and set directives.", node);
        template.addParsingProblem(problem);
      }
    }
    if (node.getType() == AssignmentInstruction.LOCAL) {
      Macro macro = getContainingMacro(node);
      if (macro == null) {
        template.addParsingProblem(new ParsingProblem("The local directive can only be used inside a function or macro.", node));
      } else {
        if (!macro.declaresVariable(node.getVarName())) {
          macro.declareVariable(node.getVarName());
        }
      }
View Full Code Here

Examples of freemarker.core.parser.ParsingProblem

  }
 
  public void visit(BuiltInExpression node) {
    super.visit(node);
    if (node.getBuiltIn() == null) {
      ParsingProblem problem = new ParsingProblem("Unknown builtin: " + node.getName(), node);
      template.addParsingProblem(problem);
    }
  }
View Full Code Here

Examples of freemarker.core.parser.ParsingProblem

  }
 
  public void visit(Macro node) {
    String macroName = node.getName();
    if (template.strictVariableDeclaration() && template.declaresVariable(macroName)) {
      ParsingProblem problem = new ParsingProblem("You already have declared a variable (or declared another macro) as " + macroName + ". You cannot reuse the variable name in the same template.", node);
      template.addParsingProblem(problem);
    }
    if (template.strictVariableDeclaration()) {
      template.declareVariable(macroName);
      TemplateElement parent=node.getParent();
      while (parent != null) {
        parent = parent.getParent();
        if (parent != null && !(parent instanceof EscapeBlock) && !(parent instanceof NoEscapeBlock) && !(parent instanceof MixedContent)) {
          ParsingProblem problem = new ParsingProblem("Macro " + macroName + " is within a " + parent.getDescription() + ". It must be a top-level element.");
          template.addParsingProblem(problem);
        }
      }
    }
    template.addMacro(node);
View Full Code Here

Examples of freemarker.core.parser.ParsingProblem

    TemplateElement parent = node;
    while (parent != null && !(parent instanceof EscapeBlock)) {
      parent = parent.getParent();
    }
    if (parent == null) {
      template.addParsingProblem(new ParsingProblem("The noescape directive only makes sense inside an escape block.", node));
    }
    EscapeBlock last = escapes.remove(escapes.size() -1);
    super.visit(node);
    escapes.add(last);
  }
View Full Code Here

Examples of freemarker.core.parser.ParsingProblem

  }
 
  public void visit(FallbackInstruction node) {
    super.visit(node);
    if (getContainingMacro(node) == null) {
      template.addParsingProblem(new ParsingProblem("The fallback directive can only be used inside a macro", 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.