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

The following examples show how to use com.google.javascript.rhino.Node#isAnd() . 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: jMutRepair_003_s.java    From coming with MIT License 6 votes vote down vote up
/** Find the l-value that the given r-value is being assigned to. */
static Node getBestLValue(Node n) {
  Node parent = n.getParent();
  boolean isFunctionDeclaration = isFunctionDeclaration(n);
  if (isFunctionDeclaration) {
    return n.getFirstChild();
  } else if (parent.isName()) {
    return parent;
  } else if (parent.isAssign()) {
    return parent.getFirstChild();
  } else if (isObjectLitKey(parent, parent.getParent())) {
    return parent;
  } else if (
      (parent.isHook() && parent.getFirstChild() != n) ||
      parent.isOr() ||
      parent.isAnd() ||
      (parent.isComma() && parent.getFirstChild() != n)) {
    return getBestLValue(parent);
  }
  return null;
}
 
Example 2
Source File: jKali_003_s.java    From coming with MIT License 6 votes vote down vote up
/** Find the l-value that the given r-value is being assigned to. */
static Node getBestLValue(Node n) {
  Node parent = n.getParent();
  boolean isFunctionDeclaration = isFunctionDeclaration(n);
  if (isFunctionDeclaration) {
    return n.getFirstChild();
  } else if (parent.isName()) {
    return parent;
  } else if (parent.isAssign()) {
    return parent.getFirstChild();
  } else if (isObjectLitKey(parent, parent.getParent())) {
    return parent;
  } else if (
      (parent.isHook() && parent.getFirstChild() != n) ||
      parent.isOr() ||
      parent.isAnd() ||
      (parent.isComma() && parent.getFirstChild() != n)) {
    return getBestLValue(parent);
  }
  return null;
}
 
Example 3
Source File: jKali_003_t.java    From coming with MIT License 6 votes vote down vote up
/** Find the l-value that the given r-value is being assigned to. */
static Node getBestLValue(Node n) {
  Node parent = n.getParent();
  boolean isFunctionDeclaration = isFunctionDeclaration(n);
  if (isFunctionDeclaration) {
    return n.getFirstChild();
  } else if (parent.isName()) {
    return parent;
  } else if (parent.isAssign()) {
    return parent.getFirstChild();
  } else if (isObjectLitKey(parent, parent.getParent())) {
    return parent;
  } else if (
      (parent.isHook() && parent.getFirstChild() != n) ||
      parent.isOr() ||
      parent.isAnd() ||
      (parent.isComma() && parent.getFirstChild() != n)) {
    return getBestLValue(parent);
  }
  return null;
}
 
Example 4
Source File: Closure_10_NodeUtil_t.java    From coming with MIT License 6 votes vote down vote up
/** Find the l-value that the given r-value is being assigned to. */
static Node getBestLValue(Node n) {
  Node parent = n.getParent();
  boolean isFunctionDeclaration = isFunctionDeclaration(n);
  if (isFunctionDeclaration) {
    return n.getFirstChild();
  } else if (parent.isName()) {
    return parent;
  } else if (parent.isAssign()) {
    return parent.getFirstChild();
  } else if (isObjectLitKey(parent, parent.getParent())) {
    return parent;
  } else if (
      (parent.isHook() && parent.getFirstChild() != n) ||
      parent.isOr() ||
      parent.isAnd() ||
      (parent.isComma() && parent.getFirstChild() != n)) {
    return getBestLValue(parent);
  }
  return null;
}
 
Example 5
Source File: Cardumen_0087_t.java    From coming with MIT License 6 votes vote down vote up
/** Find the l-value that the given r-value is being assigned to. */
static Node getBestLValue(Node n) {
  Node parent = n.getParent();
  boolean isFunctionDeclaration = isFunctionDeclaration(n);
  if (isFunctionDeclaration) {
    return n.getFirstChild();
  } else if (parent.isName()) {
    return parent;
  } else if (parent.isAssign()) {
    return parent.getFirstChild();
  } else if (isObjectLitKey(parent, parent.getParent())) {
    return parent;
  } else if (
      (parent.isHook() && parent.getFirstChild() != n) ||
      parent.isOr() ||
      parent.isAnd() ||
      (parent.isComma() && parent.getFirstChild() != n)) {
    return getBestLValue(parent);
  }
  return null;
}
 
Example 6
Source File: Cardumen_0087_s.java    From coming with MIT License 6 votes vote down vote up
/** Find the l-value that the given r-value is being assigned to. */
static Node getBestLValue(Node n) {
  Node parent = n.getParent();
  boolean isFunctionDeclaration = isFunctionDeclaration(n);
  if (isFunctionDeclaration) {
    return n.getFirstChild();
  } else if (parent.isName()) {
    return parent;
  } else if (parent.isAssign()) {
    return parent.getFirstChild();
  } else if (isObjectLitKey(parent, parent.getParent())) {
    return parent;
  } else if (
      (parent.isHook() && parent.getFirstChild() != n) ||
      parent.isOr() ||
      parent.isAnd() ||
      (parent.isComma() && parent.getFirstChild() != n)) {
    return getBestLValue(parent);
  }
  return null;
}
 
Example 7
Source File: Cardumen_0014_s.java    From coming with MIT License 6 votes vote down vote up
/** Find the l-value that the given r-value is being assigned to. */
static Node getBestLValue(Node n) {
  Node parent = n.getParent();
  boolean isFunctionDeclaration = isFunctionDeclaration(n);
  if (isFunctionDeclaration) {
    return n.getFirstChild();
  } else if (parent.isName()) {
    return parent;
  } else if (parent.isAssign()) {
    return parent.getFirstChild();
  } else if (isObjectLitKey(parent, parent.getParent())) {
    return parent;
  } else if (
      (parent.isHook() && parent.getFirstChild() != n) ||
      parent.isOr() ||
      parent.isAnd() ||
      (parent.isComma() && parent.getFirstChild() != n)) {
    return getBestLValue(parent);
  }
  return null;
}
 
Example 8
Source File: NodeUtil.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** Find the l-value that the given r-value is being assigned to. */
static Node getBestLValue(Node n) {
  Node parent = n.getParent();
  boolean isFunctionDeclaration = isFunctionDeclaration(n);
  if (isFunctionDeclaration) {
    return n.getFirstChild();
  } else if (parent.isName()) {
    return parent;
  } else if (parent.isAssign()) {
    return parent.getFirstChild();
  } else if (isObjectLitKey(parent, parent.getParent())) {
    return parent;
  } else if (
      (parent.isHook() && parent.getFirstChild() != n) ||
      parent.isOr() ||
      parent.isAnd() ||
      (parent.isComma() && parent.getFirstChild() != n)) {
    return getBestLValue(parent);
  } else if (parent.isCast()) {
    return getBestLValue(parent);
  }
  return null;
}
 
Example 9
Source File: Cardumen_00149_t.java    From coming with MIT License 6 votes vote down vote up
/** Find the l-value that the given r-value is being assigned to. */
static Node getBestLValue(Node n) {
  Node parent = n.getParent();
  boolean isFunctionDeclaration = isFunctionDeclaration(n);
  if (isFunctionDeclaration) {
    return n.getFirstChild();
  } else if (parent.isName()) {
    return parent;
  } else if (parent.isAssign()) {
    return parent.getFirstChild();
  } else if (isObjectLitKey(parent, parent.getParent())) {
    return parent;
  } else if (
      (parent.isHook() && parent.getFirstChild() != n) ||
      parent.isOr() ||
      parent.isAnd() ||
      (parent.isComma() && parent.getFirstChild() != n)) {
    return getBestLValue(parent);
  }
  return null;
}
 
Example 10
Source File: Closure_10_NodeUtil_s.java    From coming with MIT License 6 votes vote down vote up
/** Find the l-value that the given r-value is being assigned to. */
static Node getBestLValue(Node n) {
  Node parent = n.getParent();
  boolean isFunctionDeclaration = isFunctionDeclaration(n);
  if (isFunctionDeclaration) {
    return n.getFirstChild();
  } else if (parent.isName()) {
    return parent;
  } else if (parent.isAssign()) {
    return parent.getFirstChild();
  } else if (isObjectLitKey(parent, parent.getParent())) {
    return parent;
  } else if (
      (parent.isHook() && parent.getFirstChild() != n) ||
      parent.isOr() ||
      parent.isAnd() ||
      (parent.isComma() && parent.getFirstChild() != n)) {
    return getBestLValue(parent);
  }
  return null;
}
 
Example 11
Source File: Cardumen_00200_t.java    From coming with MIT License 6 votes vote down vote up
/** Find the l-value that the given r-value is being assigned to. */
static Node getBestLValue(Node n) {
  Node parent = n.getParent();
  boolean isFunctionDeclaration = isFunctionDeclaration(n);
  if (isFunctionDeclaration) {
    return n.getFirstChild();
  } else if (parent.isName()) {
    return parent;
  } else if (parent.isAssign()) {
    return parent.getFirstChild();
  } else if (isObjectLitKey(parent, parent.getParent())) {
    return parent;
  } else if (
      (parent.isHook() && parent.getFirstChild() != n) ||
      parent.isOr() ||
      parent.isAnd() ||
      (parent.isComma() && parent.getFirstChild() != n)) {
    return getBestLValue(parent);
  }
  return null;
}
 
Example 12
Source File: Cardumen_00200_s.java    From coming with MIT License 6 votes vote down vote up
/** Find the l-value that the given r-value is being assigned to. */
static Node getBestLValue(Node n) {
  Node parent = n.getParent();
  boolean isFunctionDeclaration = isFunctionDeclaration(n);
  if (isFunctionDeclaration) {
    return n.getFirstChild();
  } else if (parent.isName()) {
    return parent;
  } else if (parent.isAssign()) {
    return parent.getFirstChild();
  } else if (isObjectLitKey(parent, parent.getParent())) {
    return parent;
  } else if (
      (parent.isHook() && parent.getFirstChild() != n) ||
      parent.isOr() ||
      parent.isAnd() ||
      (parent.isComma() && parent.getFirstChild() != n)) {
    return getBestLValue(parent);
  }
  return null;
}
 
Example 13
Source File: Cardumen_0014_t.java    From coming with MIT License 5 votes vote down vote up
/** Find the best JSDoc for the given node. */
static JSDocInfo getBestJSDocInfo(Node n) {
  JSDocInfo info = n.getJSDocInfo();
  if (info == null) {
    Node parent = n.getParent();
    if (parent == null) {
      return null;
    }

    if (parent.isName()) {
      return getBestJSDocInfo(parent);
    } else if (parent.isAssign()) {
      return parent.getJSDocInfo();
    } else if (isObjectLitKey(parent, parent.getParent())) {
      return parent.getJSDocInfo();
    } else if (parent.isFunction()) {
      return parent.getJSDocInfo();
    } else if (parent.isVar() && parent.hasOneChild()) {
      return parent.getJSDocInfo();
    } else if ((parent.isHook() && parent.getFirstChild() != n) ||
               parent.isOr() ||
               parent.isAnd() ||
               (parent.isComma() && parent.getFirstChild() != n)) {
      return getBestJSDocInfo(parent);
    }
  }
  return info;
}
 
Example 14
Source File: jMutRepair_003_t.java    From coming with MIT License 5 votes vote down vote up
/** Find the best JSDoc for the given node. */
static JSDocInfo getBestJSDocInfo(Node n) {
  JSDocInfo info = n.getJSDocInfo();
  if (info == null) {
    Node parent = n.getParent();
    if (parent == null) {
      return null;
    }

    if (parent.isName()) {
      return getBestJSDocInfo(parent);
    } else if (parent.isAssign()) {
      return parent.getJSDocInfo();
    } else if (isObjectLitKey(parent, parent.getParent())) {
      return parent.getJSDocInfo();
    } else if (parent.isFunction()) {
      return parent.getJSDocInfo();
    } else if (parent.isVar() && parent.hasOneChild()) {
      return parent.getJSDocInfo();
    } else if ((parent.isHook() && parent.getFirstChild() != n) ||
               parent.isOr() ||
               parent.isAnd() ||
               (parent.isComma() && parent.getFirstChild() != n)) {
      return getBestJSDocInfo(parent);
    }
  }
  return info;
}
 
Example 15
Source File: Cardumen_00149_t.java    From coming with MIT License 5 votes vote down vote up
/** Find the best JSDoc for the given node. */
static JSDocInfo getBestJSDocInfo(Node n) {
  JSDocInfo info = n.getJSDocInfo();
  if (info == null) {
    Node parent = n.getParent();
    if (parent == null) {
      return null;
    }

    if (parent.isName()) {
      return getBestJSDocInfo(parent);
    } else if (parent.isAssign()) {
      return parent.getJSDocInfo();
    } else if (isObjectLitKey(parent, parent.getParent())) {
      return parent.getJSDocInfo();
    } else if (parent.isFunction()) {
      return parent.getJSDocInfo();
    } else if (parent.isVar() && parent.hasOneChild()) {
      return parent.getJSDocInfo();
    } else if ((parent.isHook() && parent.getFirstChild() != n) ||
               parent.isOr() ||
               parent.isAnd() ||
               (parent.isComma() && parent.getFirstChild() != n)) {
      return getBestJSDocInfo(parent);
    }
  }
  return info;
}
 
Example 16
Source File: Cardumen_0087_s.java    From coming with MIT License 5 votes vote down vote up
/** Find the best JSDoc for the given node. */
static JSDocInfo getBestJSDocInfo(Node n) {
  JSDocInfo info = n.getJSDocInfo();
  if (info == null) {
    Node parent = n.getParent();
    if (parent == null) {
      return null;
    }

    if (parent.isName()) {
      return getBestJSDocInfo(parent);
    } else if (parent.isAssign()) {
      return parent.getJSDocInfo();
    } else if (isObjectLitKey(parent, parent.getParent())) {
      return parent.getJSDocInfo();
    } else if (parent.isFunction()) {
      return parent.getJSDocInfo();
    } else if (parent.isVar() && parent.hasOneChild()) {
      return parent.getJSDocInfo();
    } else if ((parent.isHook() && parent.getFirstChild() != n) ||
               parent.isOr() ||
               parent.isAnd() ||
               (parent.isComma() && parent.getFirstChild() != n)) {
      return getBestJSDocInfo(parent);
    }
  }
  return info;
}
 
Example 17
Source File: Cardumen_0087_t.java    From coming with MIT License 5 votes vote down vote up
/** Find the best JSDoc for the given node. */
static JSDocInfo getBestJSDocInfo(Node n) {
  JSDocInfo info = n.getJSDocInfo();
  if (info == null) {
    Node parent = n.getParent();
    if (parent == null) {
      return null;
    }

    if (parent.isName()) {
      return getBestJSDocInfo(parent);
    } else if (parent.isAssign()) {
      return parent.getJSDocInfo();
    } else if (isObjectLitKey(parent, parent.getParent())) {
      return parent.getJSDocInfo();
    } else if (parent.isFunction()) {
      return parent.getJSDocInfo();
    } else if (parent.isVar() && parent.hasOneChild()) {
      return parent.getJSDocInfo();
    } else if ((parent.isHook() && parent.getFirstChild() != n) ||
               parent.isOr() ||
               parent.isAnd() ||
               (parent.isComma() && parent.getFirstChild() != n)) {
      return getBestJSDocInfo(parent);
    }
  }
  return info;
}
 
Example 18
Source File: Cardumen_00149_s.java    From coming with MIT License 5 votes vote down vote up
/** Find the best JSDoc for the given node. */
static JSDocInfo getBestJSDocInfo(Node n) {
  JSDocInfo info = n.getJSDocInfo();
  if (info == null) {
    Node parent = n.getParent();
    if (parent == null) {
      return null;
    }

    if (parent.isName()) {
      return getBestJSDocInfo(parent);
    } else if (parent.isAssign()) {
      return parent.getJSDocInfo();
    } else if (isObjectLitKey(parent, parent.getParent())) {
      return parent.getJSDocInfo();
    } else if (parent.isFunction()) {
      return parent.getJSDocInfo();
    } else if (parent.isVar() && parent.hasOneChild()) {
      return parent.getJSDocInfo();
    } else if ((parent.isHook() && parent.getFirstChild() != n) ||
               parent.isOr() ||
               parent.isAnd() ||
               (parent.isComma() && parent.getFirstChild() != n)) {
      return getBestJSDocInfo(parent);
    }
  }
  return info;
}
 
Example 19
Source File: Cardumen_00200_t.java    From coming with MIT License 5 votes vote down vote up
/** Find the best JSDoc for the given node. */
static JSDocInfo getBestJSDocInfo(Node n) {
  JSDocInfo info = n.getJSDocInfo();
  if (info == null) {
    Node parent = n.getParent();
    if (parent == null) {
      return null;
    }

    if (parent.isName()) {
      return getBestJSDocInfo(parent);
    } else if (parent.isAssign()) {
      return parent.getJSDocInfo();
    } else if (isObjectLitKey(parent, parent.getParent())) {
      return parent.getJSDocInfo();
    } else if (parent.isFunction()) {
      return parent.getJSDocInfo();
    } else if (parent.isVar() && parent.hasOneChild()) {
      return parent.getJSDocInfo();
    } else if ((parent.isHook() && parent.getFirstChild() != n) ||
               parent.isOr() ||
               parent.isAnd() ||
               (parent.isComma() && parent.getFirstChild() != n)) {
      return getBestJSDocInfo(parent);
    }
  }
  return info;
}
 
Example 20
Source File: jKali_003_s.java    From coming with MIT License 5 votes vote down vote up
/** Find the best JSDoc for the given node. */
static JSDocInfo getBestJSDocInfo(Node n) {
  JSDocInfo info = n.getJSDocInfo();
  if (info == null) {
    Node parent = n.getParent();
    if (parent == null) {
      return null;
    }

    if (parent.isName()) {
      return getBestJSDocInfo(parent);
    } else if (parent.isAssign()) {
      return parent.getJSDocInfo();
    } else if (isObjectLitKey(parent, parent.getParent())) {
      return parent.getJSDocInfo();
    } else if (parent.isFunction()) {
      return parent.getJSDocInfo();
    } else if (parent.isVar() && parent.hasOneChild()) {
      return parent.getJSDocInfo();
    } else if ((parent.isHook() && parent.getFirstChild() != n) ||
               parent.isOr() ||
               parent.isAnd() ||
               (parent.isComma() && parent.getFirstChild() != n)) {
      return getBestJSDocInfo(parent);
    }
  }
  return info;
}