public BinaryExpressionTreeImpl(Kind kind, ExpressionTree leftOperand, InternalSyntaxToken operator, ExpressionTree rightOperand) { super(kind); this.kind = Preconditions.checkNotNull(kind); this.leftOperand = Preconditions.checkNotNull(leftOperand); this.operator = operator; this.rightOperand = Preconditions.checkNotNull(rightOperand); addChild((AstNode) leftOperand); addChild(operator); addChild((AstNode) rightOperand); }
@Override public int getLine() { return getAstNode().getTokenLine(); }
@Override public AstNode getAstNode() { // TODO Dinesh: Do not override at all // TODO(Godin): provides behavioral compatibility, because this method used by AnonymousClassesTooBigCheck, but should not if (isLegacy()) { return super.getAstNode().getParent(); } else { return super.getAstNode(); } }
private ExpressionTree binaryExpression(ExpressionTree expression, Optional<List<OperatorAndOperand>> operatorAndOperands) { if (!operatorAndOperands.isPresent()) { return expression; } ExpressionTree result = expression; for (OperatorAndOperand operatorAndOperand : operatorAndOperands.get()) { result = new BinaryExpressionTreeImpl( kindMaps.getBinaryOperator((JavaPunctuator) operatorAndOperand.operator().getGrammarRuleKey()), result, operatorAndOperand.operator(), operatorAndOperand.operand()); } return result; }
@Override public void visitBinaryExpression(BinaryExpressionTree tree) { if (tree.is(Tree.Kind.PLUS, Tree.Kind.MINUS, Tree.Kind.MULTIPLY, Tree.Kind.DIVIDE)) { BinaryExpressionTreeImpl expressionTree = (BinaryExpressionTreeImpl) tree; if (expressionTree.symbolType().is("float")) { context.addIssue(tree, this, "Use a \"double\" or \"BigDecimal\" instead."); // do not look for other issues in sub-tree return; } } super.visitBinaryExpression(tree); }
private ExpressionTree binaryExpression(ExpressionTree expression, Optional<List<OperatorAndOperand>> operatorAndOperands) { if (!operatorAndOperands.isPresent()) { return expression; } ExpressionTree result = expression; for (OperatorAndOperand operatorAndOperand : operatorAndOperands.get()) { result = new BinaryExpressionTreeImpl( kindMaps.getBinaryOperator((JavaPunctuator) operatorAndOperand.operator().getGrammarRuleKey()), result, operatorAndOperand.operator(), operatorAndOperand.operand()); } return result; }
@Override public void visitBinaryExpression(BinaryExpressionTree tree) { if (tree.is(Tree.Kind.PLUS, Tree.Kind.MINUS, Tree.Kind.MULTIPLY, Tree.Kind.DIVIDE)) { if (withinStringConcatenation(tree)) { return; } BinaryExpressionTreeImpl expressionTree = (BinaryExpressionTreeImpl) tree; if (expressionTree.symbolType().is("float")) { context.reportIssue(this, tree, "Use a \"double\" or \"BigDecimal\" instead."); // do not look for other issues in sub-tree return; } } super.visitBinaryExpression(tree); }
private ExpressionTree binaryExpression(ExpressionTree expression, Optional<List<OperatorAndOperand>> operatorAndOperands) { if (!operatorAndOperands.isPresent()) { return expression; } ExpressionTree result = expression; for (OperatorAndOperand operatorAndOperand : operatorAndOperands.get()) { result = new BinaryExpressionTreeImpl( kindMaps.getBinaryOperator((JavaPunctuator) operatorAndOperand.operator().getType()), result, operatorAndOperand.operator(), operatorAndOperand.operand()); } return result; }
@Override public void visitBinaryExpression(BinaryExpressionTree tree) { if (tree.is(Tree.Kind.PLUS, Tree.Kind.MINUS, Tree.Kind.MULTIPLY, Tree.Kind.DIVIDE)) { if (withinStringConcatenation(tree)) { return; } BinaryExpressionTreeImpl expressionTree = (BinaryExpressionTreeImpl) tree; if (expressionTree.symbolType().is("float")) { context.reportIssue(this, tree, "Use a \"double\" or \"BigDecimal\" instead."); // do not look for other issues in sub-tree return; } } super.visitBinaryExpression(tree); }
private ExpressionTree binaryExpression(ExpressionTree expression, Optional<List<OperatorAndOperand>> operatorAndOperands) { if (!operatorAndOperands.isPresent()) { return expression; } ExpressionTree result = expression; for (OperatorAndOperand operatorAndOperand : operatorAndOperands.get()) { result = new BinaryExpressionTreeImpl( kindMaps.getBinaryOperator((JavaPunctuator) operatorAndOperand.operator().getGrammarRuleKey()), result, operatorAndOperand.operator(), operatorAndOperand.operand()); } return result; }