Examples of detachFromParent()


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

                     RENAME_PROPERTY_FUNCTION_NAME.equals(parent.getString())) {
            Node varNode = parent.getParent();
            if (varNode.getType() == Token.VAR) {
              varNode.removeChild(parent);
              if (!varNode.hasChildren()) {
                varNode.detachFromParent();
              }
              compiler.reportCodeChange();
            }
          }
          break;
View Full Code Here

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

        // which is the return value of the assertion.
        Node firstArg = call.getFirstChild().getNext();
        if (firstArg == null) {
          parent.replaceChild(call, NodeUtil.newUndefinedNode(call));
        } else {
          parent.replaceChild(call, firstArg.detachFromParent());
        }
      }
      compiler.reportCodeChange();
    }
  }
View Full Code Here

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

      List<Node> newReplacements = Lists.newArrayList();
      for (int i = 0; i < replacements.size() - 1; i++) {
        newReplacements.addAll(getSideEffectNodes(replacements.get(i)));
      }
      Node valueExpr = replacements.get(replacements.size() - 1);
      valueExpr.detachFromParent();
      newReplacements.add(valueExpr);
      changeProxy.replaceWith(
          parent, n, collapseReplacements(newReplacements));
    } else if (n.getType() == Token.ASSIGN && parent.getType() != Token.FOR) {
      // assignment appears in a RHS expression.  we have already
View Full Code Here

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

      // considered names in the assignment's RHS as being referenced;
      // replace the assignment with its RHS.
      // TODO(user) make the pass smarter about these cases and/or run
      // this pass and RemoveConstantExpressions together in a loop.
      Node replacement = n.getLastChild();
      replacement.detachFromParent();
      changeProxy.replaceWith(parent, n, replacement);
    } else {
      replaceTopLevelExpressionWithRhs(parent, n);
    }
  }
View Full Code Here

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

        } else {
          Node assign = n.getFirstChild();
          Node lhs = assign.getFirstChild();
          Preconditions.checkState(NodeUtil.isName(lhs));
          Node rhs = assign.getLastChild();
          lhs.addChildToBack(rhs.detachFromParent());
          var.addChildToBack(lhs.detachFromParent());
          redeclaration = true;
        }
        n = next;
      }
View Full Code Here

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

      Node value = init.getAssignedValue();
      Preconditions.checkState(value != null);
      // Check for function declarations before the value is moved in the AST.
      boolean isFunctionDeclaration = NodeUtil.isFunctionDeclaration(value);

      inlineValue(v, reference, value.detachFromParent());
      if (declaration != init) {
        Node expressRoot = init.getGrandparent();
        Preconditions.checkState(expressRoot.getType() == Token.EXPR_RESULT);
        NodeUtil.removeChild(expressRoot.getParent(), expressRoot);
      }
View Full Code Here

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

    private void inlineVariable() {
      Node defParent = def.getParent();
      Node useParent = use.getParent();
      if (NodeUtil.isAssign(def)) {
        Node rhs = def.getLastChild();
        rhs.detachFromParent();
        // Oh yes! I have grandparent to remove this.
        Preconditions.checkState(NodeUtil.isExpressionNode(defParent));
        while (defParent.getParent().getType() == Token.LABEL) {
          defParent = defParent.getParent();
        }
View Full Code Here

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

            Preconditions.checkState(
                declParent.getType() != Token.VAR || declParent.hasOneChild(),
                "AST not normalized.");

            // Remove it
            declParent.detachFromParent();

            // Add it to the new spot
            destParent.addChildToFront(declParent);

            compiler.reportCodeChange();
View Full Code Here

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

          newFnNode, args, namesToAlias, compiler.getCodingConvention());
    }

    Node newBlock = NodeUtil.getFunctionBody(newFnNode);
    // Make the newBlock insertable .
    newBlock.detachFromParent();

    if (hasArgs) {
      Node inlineResult = aliasAndInlineArguments(newBlock,
          args, namesToAlias);
      Preconditions.checkState(newBlock == inlineResult);
View Full Code Here

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

            isReturnBlock(thenBranch) && isReturnExpression(nextNode)) {
          Node thenExpr = null;
          // if(x)return; return 1 -> return x?void 0:1
          if (isReturnExpressBlock(thenBranch)) {
            thenExpr = getBlockReturnExpression(thenBranch);
            thenExpr.detachFromParent();
          } else {
            thenExpr = NodeUtil.newUndefinedNode(child);
          }

          Node elseExpr = nextNode.getFirstChild();
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.