Package com.google.javascript.rhino

Examples of com.google.javascript.rhino.Node.children()


    Node scriptRoot = new JsAst(SourceFile.fromCode(
        "template", templateJs)).getAstRoot(compiler);

    Map<String, Node> beforeTemplates = Maps.newHashMap();
    Map<String, Node> afterTemplates = Maps.newHashMap();
    for (Node templateNode : scriptRoot.children()) {
      if (templateNode.isFunction()) {
        String fnName = templateNode.getFirstChild().getQualifiedName();
        if (fnName.startsWith("before_")) {
          String templateName = fnName.substring("before_".length());
          Preconditions.checkState(
View Full Code Here


          return;
        }
        // If it is a var declaration, but no cross module names are declared
        // we also don't have to do anything.
        boolean hasCrossModuleChildren = false;
        for (Node c : parent.children()) {
          // Var child is no longer a name means it was transformed already
          // which means there was a cross module name.
          if (!c.isName() || isCrossModuleName(c.getString())) {
            hasCrossModuleChildren = true;
            break;
View Full Code Here

    if (parent == null) {
      return false;
    }

    ArrayList<Node> siblings = Lists.newArrayList(parent.children());

    int indexOfChildInParent = siblings.indexOf(child);

    switch(parent.getType()) {
      case Token.IF:
View Full Code Here

      if (name.equals(current.getQualifiedName()) &&
          current.getJSType() != null) {
        return current.getJSType();
      }

      for (Node child : current.children()) {
        queue.push(child);
      }
    }
    return null;
  }
View Full Code Here

      if (matcher.apply(current) &&
          current.getJSType() != null) {
        return current.getJSType();
      }

      for (Node child : current.children()) {
        queue.push(child);
      }
    }
    return null;
  }
View Full Code Here

      Preconditions.checkState(caseNode == executingCase
          || executingCase.getType() != Token.DEFAULT);
      Node block = executingCase.getLastChild();
      Preconditions.checkState(block.getType() == Token.BLOCK);
      if (block.hasChildren()) {
        for (Node blockChild : block.children()) {
          // If this is a block with a labelless break, it is useless.
          switch (blockChild.getType()) {
            case Token.BREAK:
              // A break to a different control structure isn't useless.
              return blockChild.getFirstChild() == null;
View Full Code Here

          Node returnNode = fnChild.getFirstChild();
          if (returnNode.getType() != Token.RETURN) {
            throw new MalformedException("RETURN node expected; found: "
                + getReadableTokenName(returnNode), returnNode);
          }
          for (Node child : returnNode.children()) {
            extractFromReturnDescendant(builder, child);
          }

          // Check that all placeholders from the message text have appropriate
          // object literal keys
View Full Code Here

  }

  public Iterable<Node> getParameters() {
    Node n = getParametersNode();
    if (n != null) {
      return n.children();
    } else {
      return Collections.emptySet();
    }
  }
View Full Code Here

    if (parent == null) {
      return false;
    }

    ArrayList<Node> siblings = Lists.newArrayList(parent.children());

    int indexOfChildInParent = siblings.indexOf(child);

    switch(parent.getType()) {
      case Token.IF:
View Full Code Here

    // the second child is a wrapper for formal parameters
    child = child.getNext();
    JsonML params = new JsonML(TagType.ParamDecl);
    element.appendChild(params);
    Iterator<Node> it = child.children().iterator();
    while (it.hasNext()) {
      JsonML param = new JsonML(TagType.IdPatt);
      Node nameNode = it.next();
      param.setAttribute(TagAttr.NAME, nameNode.getString());
      params.appendChild(param);
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.