Examples of PrintNode


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

        "  {print 'blah    blahblahblah' |escapeHtml|insertWordBreaks:8}\n";

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

    PrintNode pn0 = (PrintNode) nodes.get(0);
    assertEquals(SyntaxVersion.V2, pn0.getSyntaxVersion());
    assertEquals("$boo.foo", pn0.getExprText());
    assertEquals(0, pn0.getChildren().size());
    assertEquals("FOO", pn0.genBasePlaceholderName());
    assertEquals("{$boo.foo}", pn0.toSourceString());
    assertTrue(pn0.getExprUnion().getExpr().getChild(0) instanceof DataRefNode);

    PrintNode pn1 = (PrintNode) nodes.get(1);
    assertTrue(pn0.genSamenessKey().equals(pn1.genSamenessKey()));
    assertTrue(pn1.getExprUnion().getExpr().getChild(0) instanceof DataRefNode);

    PrintNode pn2 = (PrintNode) nodes.get(2);
    assertEquals(SyntaxVersion.V2, pn2.getSyntaxVersion());
    assertEquals("$goo + 1", pn2.getExprText());
    assertEquals(1, pn2.getChildren().size());
    PrintDirectiveNode pn2d0 = pn2.getChild(0);
    assertEquals(SyntaxVersion.V1, pn2d0.getSyntaxVersion());
    assertEquals("|noAutoescape", pn2d0.getName());
    assertEquals("XXX", pn2.genBasePlaceholderName());
    assertTrue(pn2.getExprUnion().getExpr().getChild(0) instanceof PlusOpNode);

    PrintNode pn3 = (PrintNode) nodes.get(3);
    assertEquals(SyntaxVersion.V2, pn3.getSyntaxVersion());
    assertEquals("'blah    blahblahblah'", pn3.getExprText());
    assertEquals(2, pn3.getChildren().size());
    PrintDirectiveNode pn3d0 = pn3.getChild(0);
    assertEquals(SyntaxVersion.V2, pn3d0.getSyntaxVersion());
    assertEquals("|escapeHtml", pn3d0.getName());
    PrintDirectiveNode pn3d1 = pn3.getChild(1);
    assertEquals(SyntaxVersion.V2, pn3d1.getSyntaxVersion());
    assertEquals("|insertWordBreaks", pn3d1.getName());
    assertEquals(8, ((IntegerNode) pn3d1.getArgs().get(0).getChild(0)).getValue());
    assertEquals("XXX", pn3.genBasePlaceholderName());
    assertTrue(pn3.getExprUnion().getExpr().getChild(0) instanceof StringNode);

    assertFalse(pn0.genSamenessKey().equals(pn2.genSamenessKey()));
    assertFalse(pn3.genSamenessKey().equals(pn0.genSamenessKey()));
  }
View Full Code Here

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

        "  {$boo.foo phname=\"boo_foo\"}\n";

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

    PrintNode pn0 = (PrintNode) nodes.get(0);
    assertEquals("$boo.foo", pn0.getExprText());
    assertEquals("FOO", pn0.genBasePlaceholderName());
    assertEquals("{$boo.foo}", pn0.toSourceString());

    PrintNode pn1 = (PrintNode) nodes.get(1);
    assertEquals("$boo.foo", pn1.getExprText());
    assertEquals("BOO_FOO", pn1.genBasePlaceholderName());
    assertEquals("{$boo.foo phname=\"booFoo\"}", pn1.toSourceString());
    assertEquals(SyntaxVersion.V2, pn1.getSyntaxVersion());
    assertEquals(0, pn1.getChildren().size());
    assertTrue(pn1.getExprUnion().getExpr().getChild(0) instanceof DataRefNode);

    PrintNode pn2 = (PrintNode) nodes.get(2);
    assertEquals("$boo.foo", pn2.getExprText());
    assertEquals("BOO_FOO", pn2.genBasePlaceholderName());
    assertEquals("{$boo.foo phname=\"booFoo\"}", pn2.toSourceString());

    PrintNode pn3 = (PrintNode) nodes.get(3);
    assertEquals("$boo.foo", pn3.getExprText());
    assertEquals("BOO_FOO", pn3.genBasePlaceholderName());
    assertEquals("{$boo.foo phname=\"boo_foo\"}", pn3.toSourceString());

    assertFalse(pn0.genSamenessKey().equals(pn1.genSamenessKey()));
    assertTrue(pn1.genSamenessKey().equals(pn2.genSamenessKey()));
    assertFalse(pn1.genSamenessKey().equals(pn3.genSamenessKey()));
  }
View Full Code Here

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

    parent.removeChild(indexInParent);

    // If this CssNode has componentName, add a PrintNode (with '|id' directive) to print it.
    ExprRootNode<?> componentNameExpr = node.getComponentNameExpr();
    if (componentNameExpr != null) {
      PrintNode pn =
          new PrintNode(nodeIdGen.genId(), false, new ExprUnion(componentNameExpr), null);
      pn.addChild(new PrintDirectiveNode(nodeIdGen.genId(), "|id", ""));
      parent.addChild(indexInParent, pn);
      indexInParent += 1;
    }

    // Add a RawTextNode for the selectorText. Also includes preceding dash ("-") if there is a
View Full Code Here

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

        }

        // Now rewrite the PrintNode (reusing the old node id).
        String newExprText =
            "(" + currPluralNode.getExpr().toSourceString() + ") - " + currPluralNode.getOffset();
        PrintNode newPrintNode = new PrintNode(node.getId(), node.isImplicit(), newExprText, null);
        newPrintNode.addChildren(node.getChildren());
        node.getParent().replaceChild(node, newPrintNode);
      }
    }
  }
View Full Code Here

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

      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;
        } else {
          ExprNode exprNode = newPrintNode.getExprUnion().getExpr().getChild(0);
          if (! (exprNode instanceof DataRefNode || exprNode instanceof GlobalNode)) {
            isInvalidExpr = true;
          }
        }
        if (isInvalidExpr) {
View Full Code Here

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

    // After.
    assertEquals(5, template.numChildren());
    RawTextNode rtn0 = (RawTextNode) template.getChild(0);
    assertEquals("<div class=\"AAA ", rtn0.getRawText());
    PrintNode pn1 = (PrintNode) template.getChild(1);
    assertEquals("$goo", pn1.getExprText());
    RawTextNode rtn2 = (RawTextNode) template.getChild(2);
    assertEquals("-AAA BBB ", rtn2.getRawText());
    PrintNode pn3 = (PrintNode) template.getChild(3);
    assertEquals("$goo", pn3.getExprText());
    RawTextNode rtn4 = (RawTextNode) template.getChild(4);
    assertEquals("-BBB\">", rtn4.getRawText());
  }
View Full Code Here

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

    // After.
    assertEquals(5, template.numChildren());
    RawTextNode rtn0 = (RawTextNode) template.getChild(0);
    assertEquals("<div class=\"XXX ", rtn0.getRawText());
    PrintNode pn1 = (PrintNode) template.getChild(1);
    assertEquals("$goo", pn1.getExprText());
    RawTextNode rtn2 = (RawTextNode) template.getChild(2);
    assertEquals("-XXX BBB ", rtn2.getRawText());
    PrintNode pn3 = (PrintNode) template.getChild(3);
    assertEquals("$goo", pn3.getExprText());
    RawTextNode rtn4 = (RawTextNode) template.getChild(4);
    assertEquals("-BBB\">", rtn4.getRawText());
  }
View Full Code Here

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

        "{/template}\n";

    SoyFileSetNode soyTree = SharedTestUtils.parseSoyFiles(testFileContent);

    TemplateNode template = soyTree.getChild(0).getChild(0);
    PrintNode a = (PrintNode) template.getChild(0);
    PrintNode bc = (PrintNode) template.getChild(1);
    IfNode ifNode = (IfNode) template.getChild(2);
    IfCondNode ifCondNode = (IfCondNode) ifNode.getChild(0);
    PrintNode e = (PrintNode) ifCondNode.getChild(0);
    ForeachNode foreachNode = (ForeachNode) ifCondNode.getChild(1);
    ForeachNonemptyNode foreachNonemptyNode = (ForeachNonemptyNode) foreachNode.getChild(0);
    PrintNode f = (PrintNode) foreachNonemptyNode.getChild(0);
    PrintNode gh = (PrintNode) foreachNonemptyNode.getChild(1);
    PrintDirectiveNode ghPdn = gh.getChild(0);
    MsgNode msgNode = (MsgNode) foreachNonemptyNode.getChild(2);
    MsgPlaceholderNode iPh = (MsgPlaceholderNode) msgNode.getChild(0);
    PrintNode i = (PrintNode) iPh.getChild(0);
    MsgPlaceholderNode callPh = (MsgPlaceholderNode) msgNode.getChild(1);
    CallNode callNode = (CallNode) callPh.getChild(0);
    CallParamValueNode cpvn = (CallParamValueNode) callNode.getChild(0);
    CallParamContentNode cpcn = (CallParamContentNode) callNode.getChild(1);
    PrintNode n = (PrintNode) cpcn.getChild(0);
    PrintNode fo = (PrintNode) cpcn.getChild(1);

    // Build the nearest-dependee map.
    Map<SoyNode, List<SoyNode>> allDependeesMap = (new BuildAllDependeesMapVisitor()).exec(soyTree);

    assertEquals(ImmutableList.of(template), allDependeesMap.get(a));
View Full Code Here

Examples of org.ontospread.gui.view.nodes.PrintNode

  public static DefaultGraph createGraph(Concept concept){
    DefaultGraph graph = new DefaultGraph();
    ArrayList <Node> nodes = new ArrayList <Node> ();
    ArrayList <Edge> edges = new ArrayList <Edge> ();      
    Node conceptNode = new ConceptNode(concept.getConceptDescription().getName());
    Node superClassRoot = new PrintNode( ApplicationResources.getString("superclasses.node.root"));
    Node subClassRoot = new PrintNode( ApplicationResources.getString("subclasses.node.root"));
    Node relationsRoot = new PrintNode( ApplicationResources.getString("relations.node.root"));
    Node instancesRoot = new PrintNode( ApplicationResources.getString("instances.node.root"));
    Node instancesOfRoot = new PrintNode( ApplicationResources.getString("instancesOf.node.root"));
    nodes.add(superClassRoot);
    nodes.add(subClassRoot);
    nodes.add(relationsRoot);
    nodes.add(instancesRoot);
    nodes.add(instancesOfRoot);
View Full Code Here

Examples of org.ontospread.gui.view.nodes.PrintNode

  public static DefaultGraph createGraphFromOntoSpreadState(OntologyDAO ontologyDAO, OntoSpreadState ontoSpreadState) throws Exception{
    DefaultGraph graph = new DefaultGraph();
    ArrayList <Node> nodes = new ArrayList <Node> ();
    ArrayList <Edge> edges = new ArrayList <Edge> ();
    //FIXME: Refactor, using relations and draw instances and concepts, equals
    Node root = new PrintNode( ApplicationResources.getString("info.node.root"));
    Node initialRoot = new PrintNode( ApplicationResources.getString("initial.node.root"));
    Map<String, Double> concepts = ontoSpreadState.getConcepts();
    for (ScoredConceptTO initialConcept : ontoSpreadState.getInitialConcepts()) {
      ConceptTO conceptTO = ontologyDAO.getConceptTO(initialConcept.getConceptUri());
      Node node = new InitialNode(formatActivation(conceptTO.getName(),concepts.get(conceptTO.getUri())),conceptTO.getUri());
      edges.add(new LineEdge(initialRoot,node));
      nodes.add(node);
    }

    Node spreadedRoot = new PrintNode( ApplicationResources.getString("initial.node.spreaded"));
    for (String currentSpread : ontoSpreadState.getSpreadedConcepts()) {
      ConceptTO conceptTO = ontologyDAO.getConceptTO(currentSpread);
      Node currentNode = new SpreadNode(formatActivation(conceptTO.getName(),concepts.get(conceptTO.getUri())),conceptTO.getUri());
      edges.add(new LineEdge(spreadedRoot,currentNode));
      nodes.add(currentNode);
    }

    Node activatedRoot = new PrintNode(ApplicationResources.getString("initial.node.activated") );
    for (UriDepthPair activated : ontoSpreadState.getSortedList()) {
      ConceptTO conceptTO = ontologyDAO.getConceptTO(activated.getUri())
      Node currentNode = new ActivateNode(formatActivation(conceptTO.getName(),concepts.get(conceptTO.getUri())),conceptTO.getUri());
      edges.add(new ArrowEdge(activatedRoot,currentNode));
      nodes.add(currentNode);
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.