当前位置: 首页>>代码示例>>Java>>正文


Java Node.addChildrenToFront方法代码示例

本文整理汇总了Java中com.google.javascript.rhino.Node.addChildrenToFront方法的典型用法代码示例。如果您正苦于以下问题:Java Node.addChildrenToFront方法的具体用法?Java Node.addChildrenToFront怎么用?Java Node.addChildrenToFront使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.javascript.rhino.Node的用法示例。


在下文中一共展示了Node.addChildrenToFront方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: normalizeBlocks

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Add blocks to IF, WHILE, DO, etc.
 */
private void normalizeBlocks(Node n) {
  if (NodeUtil.isControlStructure(n)
      && n.getType() != Token.LABEL
      && n.getType() != Token.SWITCH) {
    for (Node c = n.getFirstChild(); c != null; c = c.getNext()) {
      if (NodeUtil.isControlStructureCodeBlock(n,c) &&
          c.getType() != Token.BLOCK) {
        Node newBlock = new Node(Token.BLOCK);
        n.replaceChild(c, newBlock);
        if (c.getType() != Token.EMPTY) {
          newBlock.addChildrenToFront(c);
        } else {
          newBlock.setWasEmptyNode(true);
        }
        c = newBlock;
        reportChange();
      }
    }
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:24,代码来源:PrepareAst.java

示例2: extractExpression

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * @param expr The expression to extract.
 * @param injectionPoint The node before which to added the extracted
 *     expression.
 * @return The extract statement node.
 */
private Node extractExpression(Node expr, Node injectionPoint) {
  Node parent = expr.getParent();
  // The temp value is known to be constant.
  String tempName = getTempConstantValueName();

  // Replace the expression with the temporary name.
  Node replacementValueNode = Node.newString(Token.NAME, tempName);
  parent.replaceChild(expr, replacementValueNode);

  // Re-add the expression in the declaration of the temporary name.
  Node tempNameNode = Node.newString(Token.NAME, tempName);
  tempNameNode.addChildrenToBack(expr);
  Node tempVarNode = new Node(Token.VAR, tempNameNode);

  Node injectionPointParent = injectionPoint.getParent();
  injectionPointParent.addChildBefore(tempVarNode, injectionPoint);

  // If it is ASSIGN_XXX we need to assign it back to the original value.
  // Note that calling the temp constant is a lie in this case, but we do know
  // that it is not modified until after the exposed expression.
  if (NodeUtil.isAssignmentOp(parent) && !NodeUtil.isAssign(parent)) {
    Node gParent = parent.getParent();
    Node assignBack = new Node(Token.ASSIGN,
        expr.cloneTree(),
        tempNameNode.cloneNode());
    if (NodeUtil.isExpressionNode(gParent)) {
      gParent.getParent().addChildAfter(
          NodeUtil.newExpr(assignBack), gParent);
    } else {
      // TODO(user): Use comma here sucks. We might close some accuracy
      // in flow sensitive passes but as far as I know it is unavoidable.
      Node comma = new Node(Token.COMMA);
      gParent.replaceChild(parent, comma);
      comma.addChildrenToFront(assignBack);
      comma.addChildrenToFront(parent);
    }
  }
  return tempVarNode;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:46,代码来源:ExpressionDecomposer.java

示例3: insertAliasDeclaration

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
@Override
/**
 * Create the alias declaration (e.g. var $$ALIAS_NULL=null;).
 */
protected void insertAliasDeclaration(Node codeRoot) {
  Node varNode = new Node(Token.VAR);
  Node value = new Node(getTokenId());
  Node name = NodeUtil.newName(getAliasName(), varNode, getAliasName());
  name.addChildToBack(value);
  varNode.addChildToBack(name);
  codeRoot.addChildrenToFront(varNode);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:13,代码来源:AliasKeywords.java


注:本文中的com.google.javascript.rhino.Node.addChildrenToFront方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。