private void checkInvalidIn(NodeTraversal t, Node n) { if (n.isIn()) { reportIfNonObject(t, n.getLastChild(), SUSPICIOUS_IN_OPERATOR); } }
@Override public void visit(Node node) { if ((node.isName() && (node.getString().equals(MODULE) || node.getString().equals("define"))) || (node.isGetProp() && node.matchesQualifiedName("window.define")) || (node.isString() && node.getString().equals("amd") && node.getParent().isIn())) { umdTests.add(node); } } });
private void checkNegatedLeftOperandOfInOperator(NodeTraversal t, Node n) { if (n.isIn() && n.getFirstChild().isNot()) { t.report(n.getFirstChild(), SUSPICIOUS_NEGATED_LEFT_OPERAND_OF_IN_OPERATOR); } }
private void checkNegatedLeftOperandOfInOperator(NodeTraversal t, Node n) { if (n.isIn() && n.getFirstChild().isNot()) { t.report(n.getFirstChild(), SUSPICIOUS_NEGATED_LEFT_OPERAND_OF_IN_OPERATOR); } } }
private boolean opRequiresParentheses(Node n, int minPrecedence, Context context) { if (context.inForInInitClause() && n.isIn()) { // make sure this operator 'in' isn't confused with the for-loop 'in' return true; } else if (NodeUtil.isUnaryOperator(n) && isFirstOperandOfExponentiationExpression(n)) { // Unary operators are higher precedence than '**', but // ExponentiationExpression cannot expand to // UnaryExpression ** ExponentiationExpression return true; } else { return precedence(n) < minPrecedence; } }
private void addExpr(Node n, int minPrecedence, Context context) { if ((NodeUtil.precedence(n.getType()) < minPrecedence) || ((context == Context.IN_FOR_INIT_CLAUSE) && n.isIn())){ add("("); add(n, Context.OTHER); add(")"); } else { add(n, context); } }