Java Code Examples for com.google.javascript.rhino.IR#comma()

The following examples show how to use com.google.javascript.rhino.IR#comma() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Cardumen_0020_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Merge a list of nodes into a single expression.  The value of the
 * new expression is determined by the last expression in the list.
 */
private Node collapseReplacements(List<Node> replacements) {
  Node expr = null;
  for (Node rep : replacements) {
    if (rep.isExprResult()) {
      rep = rep.getFirstChild();
      rep.detachFromParent();
    }

    if (expr == null) {
      expr = rep;
    } else {
      expr = IR.comma(expr, rep);
    }
  }

  return expr;
}
 
Example 2
Source File: NameAnalyzer.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Merge a list of nodes into a single expression.  The value of the
 * new expression is determined by the last expression in the list.
 */
private Node collapseReplacements(List<Node> replacements) {
  Node expr = null;
  for (Node rep : replacements) {
    if (rep.isExprResult()) {
      rep = rep.getFirstChild();
      rep.detachFromParent();
    }

    if (expr == null) {
      expr = rep;
    } else {
      expr = IR.comma(expr, rep);
    }
  }

  return expr;
}
 
Example 3
Source File: Cardumen_00202_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Merge a list of nodes into a single expression.  The value of the
 * new expression is determined by the last expression in the list.
 */
private Node collapseReplacements(List<Node> replacements) {
  Node expr = null;
  for (Node rep : replacements) {
    if (rep.isExprResult()) {
      rep = rep.getFirstChild();
      rep.detachFromParent();
    }

    if (expr == null) {
      expr = rep;
    } else {
      expr = IR.comma(expr, rep);
    }
  }

  return expr;
}
 
Example 4
Source File: Closure_114_NameAnalyzer_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Merge a list of nodes into a single expression.  The value of the
 * new expression is determined by the last expression in the list.
 */
private Node collapseReplacements(List<Node> replacements) {
  Node expr = null;
  for (Node rep : replacements) {
    if (rep.isExprResult()) {
      rep = rep.getFirstChild();
      rep.detachFromParent();
    }

    if (expr == null) {
      expr = rep;
    } else {
      expr = IR.comma(expr, rep);
    }
  }

  return expr;
}
 
Example 5
Source File: Cardumen_0092_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Merge a list of nodes into a single expression.  The value of the
 * new expression is determined by the last expression in the list.
 */
private Node collapseReplacements(List<Node> replacements) {
  Node expr = null;
  for (Node rep : replacements) {
    if (rep.isExprResult()) {
      rep = rep.getFirstChild();
      rep.detachFromParent();
    }

    if (expr == null) {
      expr = rep;
    } else {
      expr = IR.comma(expr, rep);
    }
  }

  return expr;
}
 
Example 6
Source File: Cardumen_0092_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Merge a list of nodes into a single expression.  The value of the
 * new expression is determined by the last expression in the list.
 */
private Node collapseReplacements(List<Node> replacements) {
  Node expr = null;
  for (Node rep : replacements) {
    if (rep.isExprResult()) {
      rep = rep.getFirstChild();
      rep.detachFromParent();
    }

    if (expr == null) {
      expr = rep;
    } else {
      expr = IR.comma(expr, rep);
    }
  }

  return expr;
}
 
Example 7
Source File: Cardumen_00151_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Merge a list of nodes into a single expression.  The value of the
 * new expression is determined by the last expression in the list.
 */
private Node collapseReplacements(List<Node> replacements) {
  Node expr = null;
  for (Node rep : replacements) {
    if (rep.isExprResult()) {
      rep = rep.getFirstChild();
      rep.detachFromParent();
    }

    if (expr == null) {
      expr = rep;
    } else {
      expr = IR.comma(expr, rep);
    }
  }

  return expr;
}
 
Example 8
Source File: Closure_114_NameAnalyzer_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Merge a list of nodes into a single expression.  The value of the
 * new expression is determined by the last expression in the list.
 */
private Node collapseReplacements(List<Node> replacements) {
  Node expr = null;
  for (Node rep : replacements) {
    if (rep.isExprResult()) {
      rep = rep.getFirstChild();
      rep.detachFromParent();
    }

    if (expr == null) {
      expr = rep;
    } else {
      expr = IR.comma(expr, rep);
    }
  }

  return expr;
}
 
Example 9
Source File: Cardumen_00203_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Replace the current assign with its right hand side.
 */
void remove() {
  Node parent = assignNode.getParent();
  if (mayHaveSecondarySideEffects) {
    Node replacement = assignNode.getLastChild().detachFromParent();

    // Aggregate any expressions in GETELEMs.
    for (Node current = assignNode.getFirstChild();
         !current.isName();
         current = current.getFirstChild()) {
      if (current.isGetElem()) {
        replacement = IR.comma(
            current.getLastChild().detachFromParent(), replacement);
        replacement.copyInformationFrom(current);
      }
    }

    parent.replaceChild(assignNode, replacement);
  } else {
    Node gramps = parent.getParent();
    if (parent.isExprResult()) {
      gramps.removeChild(parent);
    } else {
      parent.replaceChild(assignNode,
          assignNode.getLastChild().detachFromParent());
    }
  }
}
 
Example 10
Source File: Cardumen_00203_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Replace the current assign with its right hand side.
 */
void remove() {
  Node parent = assignNode.getParent();
  if (mayHaveSecondarySideEffects) {
    Node replacement = assignNode.getLastChild().detachFromParent();

    // Aggregate any expressions in GETELEMs.
    for (Node current = assignNode.getFirstChild();
         !current.isName();
         current = current.getFirstChild()) {
      if (current.isGetElem()) {
        replacement = IR.comma(
            current.getLastChild().detachFromParent(), replacement);
        replacement.copyInformationFrom(current);
      }
    }

    parent.replaceChild(assignNode, replacement);
  } else {
    Node gramps = parent.getParent();
    if (parent.isExprResult()) {
      gramps.removeChild(parent);
    } else {
      parent.replaceChild(assignNode,
          assignNode.getLastChild().detachFromParent());
    }
  }
}
 
Example 11
Source File: Closure_1_RemoveUnusedVars_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Replace the current assign with its right hand side.
 */
void remove() {
  Node parent = assignNode.getParent();
  if (mayHaveSecondarySideEffects) {
    Node replacement = assignNode.getLastChild().detachFromParent();

    // Aggregate any expressions in GETELEMs.
    for (Node current = assignNode.getFirstChild();
         !current.isName();
         current = current.getFirstChild()) {
      if (current.isGetElem()) {
        replacement = IR.comma(
            current.getLastChild().detachFromParent(), replacement);
        replacement.copyInformationFrom(current);
      }
    }

    parent.replaceChild(assignNode, replacement);
  } else {
    Node gramps = parent.getParent();
    if (parent.isExprResult()) {
      gramps.removeChild(parent);
    } else {
      parent.replaceChild(assignNode,
          assignNode.getLastChild().detachFromParent());
    }
  }
}
 
Example 12
Source File: Cardumen_0021_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Replace the current assign with its right hand side.
 */
void remove() {
  Node parent = assignNode.getParent();
  if (mayHaveSecondarySideEffects) {
    Node replacement = assignNode.getLastChild().detachFromParent();

    // Aggregate any expressions in GETELEMs.
    for (Node current = assignNode.getFirstChild();
         !current.isName();
         current = current.getFirstChild()) {
      if (current.isGetElem()) {
        replacement = IR.comma(
            current.getLastChild().detachFromParent(), replacement);
        replacement.copyInformationFrom(current);
      }
    }

    parent.replaceChild(assignNode, replacement);
  } else {
    Node gramps = parent.getParent();
    if (parent.isExprResult()) {
      gramps.removeChild(parent);
    } else {
      parent.replaceChild(assignNode,
          assignNode.getLastChild().detachFromParent());
    }
  }
}
 
Example 13
Source File: Closure_1_RemoveUnusedVars_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Replace the current assign with its right hand side.
 */
void remove() {
  Node parent = assignNode.getParent();
  if (mayHaveSecondarySideEffects) {
    Node replacement = assignNode.getLastChild().detachFromParent();

    // Aggregate any expressions in GETELEMs.
    for (Node current = assignNode.getFirstChild();
         !current.isName();
         current = current.getFirstChild()) {
      if (current.isGetElem()) {
        replacement = IR.comma(
            current.getLastChild().detachFromParent(), replacement);
        replacement.copyInformationFrom(current);
      }
    }

    parent.replaceChild(assignNode, replacement);
  } else {
    Node gramps = parent.getParent();
    if (parent.isExprResult()) {
      gramps.removeChild(parent);
    } else {
      parent.replaceChild(assignNode,
          assignNode.getLastChild().detachFromParent());
    }
  }
}
 
Example 14
Source File: Cardumen_00152_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Replace the current assign with its right hand side.
 */
void remove() {
  Node parent = assignNode.getParent();
  if (mayHaveSecondarySideEffects) {
    Node replacement = assignNode.getLastChild().detachFromParent();

    // Aggregate any expressions in GETELEMs.
    for (Node current = assignNode.getFirstChild();
         !current.isName();
         current = current.getFirstChild()) {
      if (current.isGetElem()) {
        replacement = IR.comma(
            current.getLastChild().detachFromParent(), replacement);
        replacement.copyInformationFrom(current);
      }
    }

    parent.replaceChild(assignNode, replacement);
  } else {
    Node gramps = parent.getParent();
    if (parent.isExprResult()) {
      gramps.removeChild(parent);
    } else {
      parent.replaceChild(assignNode,
          assignNode.getLastChild().detachFromParent());
    }
  }
}
 
Example 15
Source File: Closure_45_RemoveUnusedVars_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Replace the current assign with its right hand side.
 */
void remove() {
  Node parent = assignNode.getParent();
  if (mayHaveSecondarySideEffects) {
    Node replacement = assignNode.getLastChild().detachFromParent();

    // Aggregate any expressions in GETELEMs.
    for (Node current = assignNode.getFirstChild();
         !current.isName();
         current = current.getFirstChild()) {
      if (current.isGetElem()) {
        replacement = IR.comma(
            current.getLastChild().detachFromParent(), replacement);
        replacement.copyInformationFrom(current);
      }
    }

    parent.replaceChild(assignNode, replacement);
  } else {
    Node gramps = parent.getParent();
    if (parent.isExprResult()) {
      gramps.removeChild(parent);
    } else {
      parent.replaceChild(assignNode,
          assignNode.getLastChild().detachFromParent());
    }
  }
}
 
Example 16
Source File: Cardumen_0093_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Replace the current assign with its right hand side.
 */
void remove() {
  Node parent = assignNode.getParent();
  if (mayHaveSecondarySideEffects) {
    Node replacement = assignNode.getLastChild().detachFromParent();

    // Aggregate any expressions in GETELEMs.
    for (Node current = assignNode.getFirstChild();
         !current.isName();
         current = current.getFirstChild()) {
      if (current.isGetElem()) {
        replacement = IR.comma(
            current.getLastChild().detachFromParent(), replacement);
        replacement.copyInformationFrom(current);
      }
    }

    parent.replaceChild(assignNode, replacement);
  } else {
    Node gramps = parent.getParent();
    if (parent.isExprResult()) {
      gramps.removeChild(parent);
    } else {
      parent.replaceChild(assignNode,
          assignNode.getLastChild().detachFromParent());
    }
  }
}
 
Example 17
Source File: Cardumen_00249_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Replace the current assign with its right hand side.
 */
void remove() {
  Node parent = assignNode.getParent();
  if (mayHaveSecondarySideEffects) {
    Node replacement = assignNode.getLastChild().detachFromParent();

    // Aggregate any expressions in GETELEMs.
    for (Node current = assignNode.getFirstChild();
         !current.isName();
         current = current.getFirstChild()) {
      if (current.isGetElem()) {
        replacement = IR.comma(
            current.getLastChild().detachFromParent(), replacement);
        replacement.copyInformationFrom(current);
      }
    }

    parent.replaceChild(assignNode, replacement);
  } else {
    Node gramps = parent.getParent();
    if (parent.isExprResult()) {
      gramps.removeChild(parent);
    } else {
      parent.replaceChild(assignNode,
          assignNode.getLastChild().detachFromParent());
    }
  }
}
 
Example 18
Source File: Closure_45_RemoveUnusedVars_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Replace the current assign with its right hand side.
 */
void remove() {
  Node parent = assignNode.getParent();
  if (mayHaveSecondarySideEffects) {
    Node replacement = assignNode.getLastChild().detachFromParent();

    // Aggregate any expressions in GETELEMs.
    for (Node current = assignNode.getFirstChild();
         !current.isName();
         current = current.getFirstChild()) {
      if (current.isGetElem()) {
        replacement = IR.comma(
            current.getLastChild().detachFromParent(), replacement);
        replacement.copyInformationFrom(current);
      }
    }

    parent.replaceChild(assignNode, replacement);
  } else {
    Node gramps = parent.getParent();
    if (parent.isExprResult()) {
      gramps.removeChild(parent);
    } else {
      parent.replaceChild(assignNode,
          assignNode.getLastChild().detachFromParent());
    }
  }
}
 
Example 19
Source File: jKali_007_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Replace the current assign with its right hand side.
 */
void remove() {
  Node parent = assignNode.getParent();
  if (mayHaveSecondarySideEffects) {
    Node replacement = assignNode.getLastChild().detachFromParent();

    // Aggregate any expressions in GETELEMs.
    for (Node current = assignNode.getFirstChild();
         !current.isName();
         current = current.getFirstChild()) {
      if (current.isGetElem()) {
        replacement = IR.comma(
            current.getLastChild().detachFromParent(), replacement);
        replacement.copyInformationFrom(current);
      }
    }

    parent.replaceChild(assignNode, replacement);
  } else {
    Node gramps = parent.getParent();
    if (parent.isExprResult()) {
      gramps.removeChild(parent);
    } else {
      parent.replaceChild(assignNode,
          assignNode.getLastChild().detachFromParent());
    }
  }
}
 
Example 20
Source File: Cardumen_0021_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Replace the current assign with its right hand side.
 */
void remove() {
  Node parent = assignNode.getParent();
  if (mayHaveSecondarySideEffects) {
    Node replacement = assignNode.getLastChild().detachFromParent();

    // Aggregate any expressions in GETELEMs.
    for (Node current = assignNode.getFirstChild();
         !current.isName();
         current = current.getFirstChild()) {
      if (current.isGetElem()) {
        replacement = IR.comma(
            current.getLastChild().detachFromParent(), replacement);
        replacement.copyInformationFrom(current);
      }
    }

    parent.replaceChild(assignNode, replacement);
  } else {
    Node gramps = parent.getParent();
    if (parent.isExprResult()) {
      gramps.removeChild(parent);
    } else {
      parent.replaceChild(assignNode,
          assignNode.getLastChild().detachFromParent());
    }
  }
}