Java Code Examples for com.google.javascript.rhino.Node#getInputId()

The following examples show how to use com.google.javascript.rhino.Node#getInputId() . 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: GlobalVarReferenceMap.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Updates the internal reference map based on the provided parameters. If
 * {@code scriptRoot} is not SCRIPT, it basically replaces the internal map
 * with the new one, otherwise it replaces all the information associated to
 * the given script.
 *
 * @param refMapPatch The reference map result of a
 *     {@link ReferenceCollectingCallback} pass which might be collected from
 *     the whole AST or just a sub-tree associated to a SCRIPT node.
 * @param root AST sub-tree root on which reference collection was done.
 */
void updateGlobalVarReferences(Map<Var, ReferenceCollection>
    refMapPatch, Node root) {
  if (refMap == null || !root.isScript()) {
    resetGlobalVarReferences(refMapPatch);
    return;
  }

  InputId inputId = root.getInputId();
  Preconditions.checkNotNull(inputId);
  // Note there are two assumptions here (i) the order of compiler inputs
  // has not changed and (ii) all references are in the order they appear
  // in AST (this is enforced in ReferenceCollectionCallback).
  removeScriptReferences(inputId);
  for (Entry<Var, ReferenceCollection> entry : refMapPatch.entrySet()) {
    Var var = entry.getKey();
    if (var.isGlobal()) {
      replaceReferences(var.getName(), inputId, entry.getValue());
    }
  }
}
 
Example 2
Source File: jMutRepair_003_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * @param n The node.
 * @return The InputId property on the node or its ancestors.
 */
public static InputId getInputId(Node n) {
  while (n != null && !n.isScript()) {
    n = n.getParent();
  }

  return (n != null && n.isScript()) ? n.getInputId() : null;
}
 
Example 3
Source File: NodeUtil.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param n The node.
 * @return The InputId property on the node or its ancestors.
 */
public static InputId getInputId(Node n) {
  while (n != null && !n.isScript()) {
    n = n.getParent();
  }

  return (n != null && n.isScript()) ? n.getInputId() : null;
}
 
Example 4
Source File: NodeTraversal.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Traverses a branch.
 */
@SuppressWarnings("fallthrough")
private void traverseBranch(Node n, Node parent) {
  int type = n.getType();
  if (type == Token.SCRIPT) {
    inputId = n.getInputId();
    sourceName = getSourceName(n);
  }

  curNode = n;
  if (!callback.shouldTraverse(this, n, parent)) return;

  switch (type) {
    case Token.FUNCTION:
      traverseFunction(n, parent);
      break;

    default:
      for (Node child = n.getFirstChild(); child != null; ) {
        // child could be replaced, in which case our child node
        // would no longer point to the true next
        Node next = child.getNext();
        traverseBranch(child, n);
        child = next;
      }
      break;
  }

  curNode = n;
  callback.visit(this, n, parent);
}
 
Example 5
Source File: Closure_37_NodeTraversal_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Traverses a branch.
 */
@SuppressWarnings("fallthrough")
private void traverseBranch(Node n, Node parent) {
  int type = n.getType();
  if (type == Token.SCRIPT) {
    inputId = n.getInputId();
    sourceName = getSourceName(n);
  }

  curNode = n;
  if (!callback.shouldTraverse(this, n, parent)) return;

  switch (type) {
    case Token.FUNCTION:
      traverseFunction(n, parent);
      break;

    default:
      for (Node child = n.getFirstChild(); child != null; ) {
        // child could be replaced, in which case our child node
        // would no longer point to the true next
        Node next = child.getNext();
        traverseBranch(child, n);
        child = next;
      }
      break;
  }

  curNode = n;
  callback.visit(this, n, parent);
}
 
Example 6
Source File: Closure_37_NodeTraversal_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Traverses a branch.
 */
@SuppressWarnings("fallthrough")
private void traverseBranch(Node n, Node parent) {
  int type = n.getType();
  if (type == Token.SCRIPT) {
    inputId = n.getInputId();
    sourceName = getSourceName(n);
  }

  curNode = n;
  if (!callback.shouldTraverse(this, n, parent)) return;

  switch (type) {
    case Token.FUNCTION:
      traverseFunction(n, parent);
      break;

    default:
      for (Node child = n.getFirstChild(); child != null; ) {
        // child could be replaced, in which case our child node
        // would no longer point to the true next
        Node next = child.getNext();
        traverseBranch(child, n);
        child = next;
      }
      break;
  }

  curNode = n;
  callback.visit(this, n, parent);
}
 
Example 7
Source File: Closure_10_NodeUtil_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * @param n The node.
 * @return The InputId property on the node or its ancestors.
 */
public static InputId getInputId(Node n) {
  while (n != null && !n.isScript()) {
    n = n.getParent();
  }

  return (n != null && n.isScript()) ? n.getInputId() : null;
}
 
Example 8
Source File: Closure_10_NodeUtil_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * @param n The node.
 * @return The InputId property on the node or its ancestors.
 */
public static InputId getInputId(Node n) {
  while (n != null && !n.isScript()) {
    n = n.getParent();
  }

  return (n != null && n.isScript()) ? n.getInputId() : null;
}
 
Example 9
Source File: jMutRepair_003_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * @param n The node.
 * @return The InputId property on the node or its ancestors.
 */
public static InputId getInputId(Node n) {
  while (n != null && !n.isScript()) {
    n = n.getParent();
  }

  return (n != null && n.isScript()) ? n.getInputId() : null;
}
 
Example 10
Source File: Cardumen_00200_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * @param n The node.
 * @return The InputId property on the node or its ancestors.
 */
public static InputId getInputId(Node n) {
  while (n != null && !n.isScript()) {
    n = n.getParent();
  }

  return (n != null && n.isScript()) ? n.getInputId() : null;
}
 
Example 11
Source File: jKali_003_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * @param n The node.
 * @return The InputId property on the node or its ancestors.
 */
public static InputId getInputId(Node n) {
  while (n != null && !n.isScript()) {
    n = n.getParent();
  }

  return (n != null && n.isScript()) ? n.getInputId() : null;
}
 
Example 12
Source File: jKali_003_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * @param n The node.
 * @return The InputId property on the node or its ancestors.
 */
public static InputId getInputId(Node n) {
  while (n != null && !n.isScript()) {
    n = n.getParent();
  }

  return (n != null && n.isScript()) ? n.getInputId() : null;
}
 
Example 13
Source File: Cardumen_0087_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * @param n The node.
 * @return The InputId property on the node or its ancestors.
 */
public static InputId getInputId(Node n) {
  while (n != null && !n.isScript()) {
    n = n.getParent();
  }

  return (n != null && n.isScript()) ? n.getInputId() : null;
}
 
Example 14
Source File: Cardumen_0087_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * @param n The node.
 * @return The InputId property on the node or its ancestors.
 */
public static InputId getInputId(Node n) {
  while (n != null && !n.isScript()) {
    n = n.getParent();
  }

  return (n != null && n.isScript()) ? n.getInputId() : null;
}
 
Example 15
Source File: Cardumen_0014_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * @param n The node.
 * @return The InputId property on the node or its ancestors.
 */
public static InputId getInputId(Node n) {
  while (n != null && !n.isScript()) {
    n = n.getParent();
  }

  return (n != null && n.isScript()) ? n.getInputId() : null;
}
 
Example 16
Source File: Cardumen_0014_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * @param n The node.
 * @return The InputId property on the node or its ancestors.
 */
public static InputId getInputId(Node n) {
  while (n != null && !n.isScript()) {
    n = n.getParent();
  }

  return (n != null && n.isScript()) ? n.getInputId() : null;
}
 
Example 17
Source File: Cardumen_00149_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * @param n The node.
 * @return The InputId property on the node or its ancestors.
 */
public static InputId getInputId(Node n) {
  while (n != null && !n.isScript()) {
    n = n.getParent();
  }

  return (n != null && n.isScript()) ? n.getInputId() : null;
}
 
Example 18
Source File: Cardumen_00149_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * @param n The node.
 * @return The InputId property on the node or its ancestors.
 */
public static InputId getInputId(Node n) {
  while (n != null && !n.isScript()) {
    n = n.getParent();
  }

  return (n != null && n.isScript()) ? n.getInputId() : null;
}
 
Example 19
Source File: Cardumen_00200_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * @param n The node.
 * @return The InputId property on the node or its ancestors.
 */
public static InputId getInputId(Node n) {
  while (n != null && !n.isScript()) {
    n = n.getParent();
  }

  return (n != null && n.isScript()) ? n.getInputId() : null;
}
 
Example 20
Source File: AstValidator.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private void validateHasInputId(Node n) {
  InputId inputId = n.getInputId();
  if (inputId == null) {
    violation("Missing 'input id' annotation.", n);
  }
}