Package com.google.template.soy.soytree

Examples of com.google.template.soy.soytree.CallBasicNode


        // Creates a new call node, but with a different target name.
        // TODO: Create a CallNode.withNewName() convenience method.
        CallNode newCallNode;
        if (callNode instanceof CallBasicNode) {
          // For simplicity, use the full callee name as the source callee name.
          newCallNode = new CallBasicNode(
              callNode.getId(), derivedCalleeName, derivedCalleeName, false,
              callNode.isPassingData(), callNode.isPassingAllData(), callNode.getDataExpr(),
              callNode.getUserSuppliedPlaceholderName(), callNode.getSyntaxVersion(),
              callNode.getEscapingDirectiveNames());
        } else {
View Full Code Here


    }

    // Change this call to pass data="all" and remove all params. (We reuse the node id.)
    CallNode newCallNode;
    if (node instanceof CallBasicNode) {
      CallBasicNode nodeCast = (CallBasicNode) node;
      newCallNode = new CallBasicNode(
          node.getId(), nodeCast.getCalleeName(), nodeCast.getSrcCalleeName(), false, true,
          true, null, node.getUserSuppliedPlaceholderName(), SyntaxVersion.V2,
          node.getEscapingDirectiveNames());
    } else {
      CallDelegateNode nodeCast = (CallDelegateNode) node;
      newCallNode = new CallDelegateNode(
          node.getId(), nodeCast.getDelCalleeName(), nodeCast.getDelCalleeVariantExpr(), false,
          nodeCast.allowsEmptyDefault(), true, true, null, node.getUserSuppliedPlaceholderName(),
          node.getEscapingDirectiveNames());
    }
    node.getParent().replaceChild(node, newCallNode);
  }
View Full Code Here

        "  {/call}\n";

    List<StandaloneNode> nodes = parseTemplateBody(templateBody);
    assertEquals(5, nodes.size());

    CallBasicNode cn0 = (CallBasicNode) nodes.get(0);
    assertEquals(SyntaxVersion.V2, cn0.getSyntaxVersion());
    assertEquals(null, cn0.getCalleeName());
    assertEquals(".booTemplate_", cn0.getSrcCalleeName());
    assertEquals(false, cn0.isPassingData());
    assertEquals(false, cn0.isPassingAllData());
    assertEquals(null, cn0.getDataExpr());
    assertEquals("XXX", cn0.genBasePlaceholderName());
    assertEquals(0, cn0.numChildren());

    CallBasicNode cn1 = (CallBasicNode) nodes.get(1);
    assertEquals(SyntaxVersion.V1, cn1.getSyntaxVersion());
    assertEquals(null, cn1.getCalleeName());
    assertEquals("foo.goo.mooTemplate", cn1.getSrcCalleeName());
    assertEquals(true, cn1.isPassingData());
    assertEquals(true, cn1.isPassingAllData());
    assertEquals(null, cn1.getDataExpr());
    assertFalse(cn1.genSamenessKey().equals(cn0.genSamenessKey()));
    assertEquals(0, cn1.numChildren());

    CallBasicNode cn2 = (CallBasicNode) nodes.get(2);
    assertEquals(SyntaxVersion.V2, cn2.getSyntaxVersion());
    assertEquals(null, cn2.getCalleeName());
    assertEquals(".zooTemplate", cn2.getSrcCalleeName());
    assertEquals(true, cn2.isPassingData());
    assertEquals(false, cn2.isPassingAllData());
    assertTrue(cn2.getDataExpr().getChild(0) != null);
    assertEquals("$animals", cn2.getDataExpr().toSourceString());
    assertEquals(3, cn2.numChildren());

    {
      final CallParamValueNode cn2cpvn0 = (CallParamValueNode) cn2.getChild(0);
      assertEquals("yoo", cn2cpvn0.getKey());
      assertEquals("round($too)", cn2cpvn0.getValueExprText());
      assertTrue(cn2cpvn0.getValueExprUnion().getExpr().getChild(0) instanceof FunctionNode);
    }

    {
      final CallParamContentNode cn2cpcn1 = (CallParamContentNode) cn2.getChild(1);
      assertEquals("woo", cn2cpcn1.getKey());
      assertNull(cn2cpcn1.getContentKind());
      assertEquals("poo", ((RawTextNode) cn2cpcn1.getChild(0)).getRawText());
    }

    {
      final CallParamContentNode cn2cpcn2 = (CallParamContentNode) cn2.getChild(2);
      assertEquals("doo", cn2cpcn2.getKey());
      assertNotNull(cn2cpcn2.getContentKind());
      assertEquals(ContentKind.HTML, cn2cpcn2.getContentKind());
      assertEquals("doopoo", ((RawTextNode) cn2cpcn2.getChild(0)).getRawText());
    }

    CallBasicNode cn3 = (CallBasicNode) nodes.get(3);
    assertEquals(SyntaxVersion.V2, cn3.getSyntaxVersion());
    assertEquals(null, cn3.getCalleeName());
    assertEquals(".booTemplate_", cn3.getSrcCalleeName());
    assertEquals(false, cn3.isPassingData());
    assertEquals(false, cn3.isPassingAllData());
    assertEquals(null, cn3.getDataExpr());
    assertEquals("XXX", cn3.genBasePlaceholderName());
    assertEquals(0, cn3.numChildren());

    CallBasicNode cn4 = (CallBasicNode) nodes.get(4);
    assertEquals(SyntaxVersion.V2, cn4.getSyntaxVersion());
    assertEquals(null, cn4.getCalleeName());
    assertEquals(".zooTemplate", cn4.getSrcCalleeName());
    assertEquals(true, cn4.isPassingData());
    assertEquals(false, cn4.isPassingAllData());
    assertTrue(cn4.getDataExpr().getChild(0) != null);
    assertEquals("$animals", cn4.getDataExpr().toSourceString());
    assertEquals(4, cn4.numChildren());

    {
      final CallParamValueNode cn4cpvn0 = (CallParamValueNode) cn4.getChild(0);
      assertEquals("yoo", cn4cpvn0.getKey());
      assertEquals("round($too)", cn4cpvn0.getValueExprText());
      assertTrue(cn4cpvn0.getValueExprUnion().getExpr().getChild(0) instanceof FunctionNode);
    }

    {
      final CallParamContentNode cn4cpcn1 = (CallParamContentNode) cn4.getChild(1);
      assertEquals("woo", cn4cpcn1.getKey());
      assertNull(cn4cpcn1.getContentKind());
      assertEquals("poo", ((RawTextNode) cn4cpcn1.getChild(0)).getRawText());
    }

    {
      final CallParamValueNode cn4cpvn2 = (CallParamValueNode) cn4.getChild(2);
      assertEquals("zoo", cn4cpvn2.getKey());
      assertEquals("0", cn4cpvn2.getValueExprText());
    }

    {
      final CallParamContentNode cn4cpcn3 = (CallParamContentNode) cn4.getChild(3);
      assertEquals("doo", cn4cpcn3.getKey());
      assertNotNull(cn4cpcn3.getContentKind());
      assertEquals(ContentKind.HTML, cn4cpcn3.getContentKind());
      assertEquals("doopoo", ((RawTextNode) cn4cpcn3.getChild(0)).getRawText());
    }
View Full Code Here

        "  {/delcall}\n";

    List<StandaloneNode> nodes = parseTemplateBody(templateBody);
    assertEquals(3, nodes.size());

    CallBasicNode cn0 = (CallBasicNode) nodes.get(0);
    assertEquals("BOO_TEMPLATE", cn0.genBasePlaceholderName());
    assertEquals(SyntaxVersion.V2, cn0.getSyntaxVersion());
    assertEquals(null, cn0.getCalleeName());
    assertEquals(".booTemplate_", cn0.getSrcCalleeName());
    assertEquals(false, cn0.isPassingData());
    assertEquals(false, cn0.isPassingAllData());
    assertEquals(null, cn0.getDataExpr());
    assertEquals(0, cn0.numChildren());

    CallBasicNode cn1 = (CallBasicNode) nodes.get(1);

    CallDelegateNode cn2 = (CallDelegateNode) nodes.get(2);
    assertEquals("SECRET_ZOO", cn2.genBasePlaceholderName());
    assertEquals(SyntaxVersion.V2, cn2.getSyntaxVersion());
    assertEquals("MySecretFeature.zooTemplate", cn2.getDelCalleeName());
    assertEquals(true, cn2.isPassingData());
    assertEquals(false, cn2.isPassingAllData());
    assertTrue(cn2.getDataExpr().getChild(0) != null);
    assertEquals("$animals", cn2.getDataExpr().toSourceString());
    assertEquals(1, cn2.numChildren());

    assertFalse(cn0.genSamenessKey().equals(cn1.genSamenessKey()))// CallNodes are never same
    assertFalse(cn2.genSamenessKey().equals(cn0.genSamenessKey()));
  }
View Full Code Here

TOP

Related Classes of com.google.template.soy.soytree.CallBasicNode

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.