Package com.google.template.soy.soytree

Examples of com.google.template.soy.soytree.SoyNode$MsgBlockNode


  public void testHandleLiteral() {

    SoyFileSetNode soyTree = SharedTestUtils.parseSoyCode("{css selected-option}");
    (new HandleCssCommandVisitor(CssHandlingScheme.LITERAL)).exec(soyTree);
    SoyNode soyNode = SharedTestUtils.getNode(soyTree, 0);
    assertEquals("selected-option", ((RawTextNode) soyNode).getRawText());
  }
View Full Code Here


  public void testHandleReference() {

    SoyFileSetNode soyTree = SharedTestUtils.parseSoyCode("{css $cssSelectedOption}");
    (new HandleCssCommandVisitor(CssHandlingScheme.REFERENCE)).exec(soyTree);
    SoyNode soyNode = SharedTestUtils.getNode(soyTree, 0);
    assertEquals("$cssSelectedOption", ((PrintNode) soyNode).getExprText());

    soyTree = SharedTestUtils.parseSoyCode("{css CSS_SELECTED_OPTION}");
    (new HandleCssCommandVisitor(CssHandlingScheme.REFERENCE)).exec(soyTree);
    soyNode = SharedTestUtils.getNode(soyTree, 0);
View Full Code Here

    for (List<SoyNode> potentialDependeeFrame : potentialDependeeFrames) {
      // We must iterate in reverse if we wish to encounter the dependees in distance order (nearest
      // dependee first).
      for (int i = potentialDependeeFrame.size() - 1; i >= 0; i--) {
        SoyNode potentialDependee = potentialDependeeFrame.get(i);
        if (isDependent(potentialDependee, node, topLevelRefs)) {
          allDependees.add(potentialDependee);
        }
      }
    }
View Full Code Here

    private void propagateAcrossDisjunction(ParentSoyNode<?> node) {
      try {
        // All the branches of an {if} or {switch} should return compatible contexts, so that we can
        // figure out the end context of the branch as a whole.
        Iterator<? extends SoyNode> childIt = node.getChildren().iterator();
        SoyNode firstBranch = childIt.next();
        Context out = infer(firstBranch, context);
        boolean sawElseOrDefault = false;
        while (childIt.hasNext()) {
          SoyNode branch = childIt.next();
          Context brOut = infer(branch, context);
          Context combined = Context.union(out, brOut);
          if (combined.isErrorContext()) {
            throw SoyAutoescapeException.createWithNode(
                (node instanceof IfNode ?
                    "{if} command branch ends in a different context than preceding branches: " :
                    "{switch} command case ends in a different context than preceding cases: ") +
                    branch.toSourceString(),
                branch);
          }
          out = combined;
          if (branch instanceof IfElseNode || branch instanceof SwitchDefaultNode) {
            sawElseOrDefault = true;
View Full Code Here

  private void moveGoogMsgNodeEarlierHelper(GoogMsgNode googMsgNode, List<SoyNode> allDependees) {

    BlockNode newParent;
    int indexUnderNewParent;

    SoyNode nearestDependee = allDependees.get(0);
    if (nearestDependee instanceof LocalVarInlineNode) {
      newParent = (BlockNode) nearestDependee.getParent();
      indexUnderNewParent = newParent.getChildIndex((LocalVarInlineNode) nearestDependee) + 1;
    } else if (nearestDependee instanceof BlockNode) {
      newParent = (BlockNode) nearestDependee;
      indexUnderNewParent = 0;
    } else {
View Full Code Here

   * @param indicesToNode The indices to reach the desired node to retrieve. E.g. To retrieve the
   *     first child of the template, simply pass a single 0.
   * @return The desired node in the parse tree.
   */
  public static SoyNode getNode(SoyFileSetNode soyTree, int... indicesToNode) {
    SoyNode node = soyTree.getChild(0).getChild(0)// initially set to TemplateNode
    for (int index : indicesToNode) {
      node = ((ParentSoyNode<?>) node).getChild(index);
    }
    return node;
  }
View Full Code Here

TOP

Related Classes of com.google.template.soy.soytree.SoyNode$MsgBlockNode

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.