Package com.google.template.soy.base

Examples of com.google.template.soy.base.IdGenerator


    // This pass simply finds all the CssNodes.
    visitChildren(node);

    // Perform the replacments.
    IdGenerator nodeIdGen = node.getNearestAncestor(SoyFileSetNode.class).getNodeIdGenerator();
    for (CssNode cssNode : cssNodes) {

      StandaloneNode newNode;

      if (cssHandlingScheme == CssHandlingScheme.LITERAL) {
        newNode = new RawTextNode(nodeIdGen.genId(), cssNode.getCommandText());

      } else if (cssHandlingScheme == CssHandlingScheme.REFERENCE) {
        PrintNode newPrintNode =
            new PrintNode(nodeIdGen.genId(), false, cssNode.getCommandText(), null);
        newPrintNode.addChild(new PrintDirectiveNode(nodeIdGen.genId(), "|noAutoescape", ""));
        newNode = newPrintNode;
        // Check that the expression is a valid reference.
        boolean isInvalidExpr = false;
        if (newPrintNode.getExprUnion().getExpr() == null) {
          isInvalidExpr = true;
View Full Code Here


   * @throws SoySyntaxException If there is an error reading the file or a syntax error is found.
   */
  public Pair<SoyFileSetNode, List<SoyFileSupplier.Version>> parseWithVersions()
      throws SoySyntaxException {

    IdGenerator nodeIdGen = new IncrementingIdGenerator();
    SoyFileSetNode soyTree = new SoyFileSetNode(nodeIdGen.genId(), nodeIdGen);
    ImmutableList.Builder<SoyFileSupplier.Version> versions = ImmutableList.builder();

    for (SoyFileSupplier soyFileSupplier : soyFileSuppliers) {
      Pair<SoyFileNode, SoyFileSupplier.Version> fileAndVersion =
          parseSoyFileHelper(soyFileSupplier, nodeIdGen);
View Full Code Here

    // Clone the node.
    @SuppressWarnings("unchecked")
    T clone = (T) origNode.clone();

    // Generate new ids.
    IdGenerator nodeIdGen = origNode.getNearestAncestor(SoyFileSetNode.class).getNodeIdGenerator();
    (new GenNewIdsVisitor(nodeIdGen)).exec(clone);

    return clone;
  }
View Full Code Here

    // This pass simply finds all the MsgNodes.
    visitChildren(node);

    // Perform the replacments.
    IdGenerator nodeIdGen = node.getNearestAncestor(SoyFileSetNode.class).getNodeIdGenerator();
    for (MsgNode msgNode : msgNodes) {
      replaceMsgNodeHelper(msgNode, nodeIdGen);
    }
  }
View Full Code Here

          pe.getMessage().contains("Found on line 2"));
    }

    // The line number is correct even when the template doesn't start on line 1.
    try {
      IdGenerator nodeIdGen = new IncrementingIdGenerator();
      (new TemplateParser("foo", "test.soy", /* start line number */ 2, nodeIdGen))
          .MaybeWhitespace("ErrorMessage");
      fail("Should have failed with a ParseException");
    } catch (ParseException pe) {
      assertTrue("Expected [Found on line 2], received: " + pe.getMessage(),
View Full Code Here

   * @throws ParseException When the given input has a parse error.
   * @return The parse tree nodes created.
   */
  private static List<StandaloneNode> parseTemplateBody(String input)
      throws SoySyntaxException, TokenMgrError, ParseException {
    IdGenerator nodeIdGen = new IncrementingIdGenerator();
    return (new TemplateParser(input, "test.soy", /* start line number */ 1, nodeIdGen))
        .parseTemplateBody();
  }
View Full Code Here

   * @throws TokenMgrError When the given input has a token error.
   * @throws ParseException When the given input has a parse error.
   */
  private static void parseMaybeWhitespace(String errorMessage, String input)
      throws SoySyntaxException, TokenMgrError, ParseException {
    IdGenerator nodeIdGen = new IncrementingIdGenerator();
    (new TemplateParser(input, "test.soy", /* start line number */ 1, nodeIdGen))
        .MaybeWhitespace(errorMessage);
  }
View Full Code Here

      "{/template}");


  public final void testClone() throws Exception {

    IdGenerator nodeIdGen = new IncrementingIdGenerator();
    SoyFileSetNode fileSetNode = new SoyFileSetNode(nodeIdGen.genId(), nodeIdGen);
    SoyFileNode fileNode =
        (new SoyFileParser(SOY_SOURCE_FOR_TESTING_CLONING, SoyFileKind.SRC, "test.soy", nodeIdGen))
            .parseSoyFile();
    fileSetNode.addChild(fileNode);
View Full Code Here

  }


  public final void testCloneWithNewIds() throws Exception {

    IdGenerator nodeIdGen = new IncrementingIdGenerator();
    SoyFileSetNode fileSetNode = new SoyFileSetNode(nodeIdGen.genId(), nodeIdGen);
    SoyFileNode fileNode =
        (new SoyFileParser(SOY_SOURCE_FOR_TESTING_CLONING, SoyFileKind.SRC, "test.soy", nodeIdGen))
            .parseSoyFile();
    fileSetNode.addChild(fileNode);
View Full Code Here

  }


  public final void testMsgHtmlTagNode() throws Exception {

    IdGenerator nodeIdGen = new IncrementingIdGenerator();
    SoyFileSetNode fileSetNode = new SoyFileSetNode(nodeIdGen.genId(), nodeIdGen);
    SoyFileNode fileNode =
        (new SoyFileParser(SOY_SOURCE_FOR_TESTING_CLONING, SoyFileKind.SRC, "test.soy", nodeIdGen))
            .parseSoyFile();
    fileSetNode.addChild(fileNode);
View Full Code Here

TOP

Related Classes of com.google.template.soy.base.IdGenerator

Copyright © 2018 www.massapicom. 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.