Examples of detachFromParent()


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

              key, callName, nameGenerator, key.getString());
          key.setString(rename);
          // Prevent standard renaming by marking the key as quoted.
          key.putBooleanProp(Node.QUOTED_PROP, true);
        }
        arg.detachFromParent();
        parent.replaceChild(n, arg);
        compiler.reportCodeChange();
      } else {
        compiler.report(t.makeError(n, INVALID_GENERATOR_PARAMETER));
      }
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);
      compiler.reportChangeToEnclosingScope(ref.getNode());
      inlineValue(v, ref, value.detachFromParent());
      if (decl != init) {
        Node expressRoot = init.getGrandparent();
        Preconditions.checkState(expressRoot.isExprResult());
        NodeUtil.removeChild(expressRoot.getParent(), expressRoot);
      }
View Full Code Here

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

            Preconditions.checkState(
                !declParent.isVar() || 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()

                // Normalize: "let i = 0, j = 0;" becomes "let i = 0; let j = 0;"
                while (declaration.getChildCount() > 1) {
                  Node name = declaration.getLastChild();
                  grandParent.addChildAfter(
                      IR.declaration(
                          name.detachFromParent(), declaration.getType())
                          .useSourceInfoIfMissingFromForTree(declaration),
                      declaration);
                }

                // Change declaration to assignment, or just drop it if there's
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.isAssign() && !parent.isFor()) {
      // 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()

      // Verify the symbol table.
      ErrorManager symbolTableErrorManager =
          new BlackHoleErrorManager(compiler);
      Node expectedRoot = parseExpectedJs(expected);
      expectedRoot.detachFromParent();

      JSError[] stErrors = symbolTableErrorManager.getErrors();
      if (expectedSymbolTableError != null) {
        assertEquals("There should be one error.", 1, stErrors.length);
        assertEquals(expectedSymbolTableError, stErrors[0].getType());
View Full Code Here

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

    Node right = subtree.getLastChild();
    // Only names
    if (left.getType() == Token.NAME
        && right.getType() == Token.NAME
        && left.getString().equals(right.getString())) {
      subtree.getParent().replaceChild(subtree, right.detachFromParent());
      reportCodeChange();
      return right;
    }
    return subtree;
  }
View Full Code Here

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

      // Collapse the scopes.
      for (Node scopeCall : traversal.getScopeCalls()) {
        Node expressionWithScopeCall = scopeCall.getParent();
        Node scopeClosureBlock = scopeCall.getLastChild().getLastChild();
        scopeClosureBlock.detachFromParent();
        expressionWithScopeCall.getParent().replaceChild(
            expressionWithScopeCall,
            scopeClosureBlock);
        NodeUtil.tryMergeBlock(scopeClosureBlock);
      }
View Full Code Here

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

        + input.getName());
    inputsById.remove(id);
    externs.remove(input);
    Node root = input.getAstRoot(this);
    if (root != null) {
      root.detachFromParent();
    }
  }

  @Override
  public CompilerInput newExternInput(String name) {
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.