use of org.sonar.plugins.java.api.tree.ExpressionTree in project sonar-java by SonarSource.
the class MethodInvocationTreeImpl method firstToken.
@Override
public SyntaxToken firstToken() {
if (typeArguments() != null && methodSelect.is(Tree.Kind.MEMBER_SELECT)) {
ExpressionTree expression = ((MemberSelectExpressionTree) methodSelect).expression();
SyntaxToken firstToken = expression.firstToken();
if (firstToken != null) {
return firstToken;
}
}
return super.firstToken();
}
use of org.sonar.plugins.java.api.tree.ExpressionTree in project sonar-java by SonarSource.
the class MemberSelectExpressionTreeImpl method completeWithExpression.
public MemberSelectExpressionTreeImpl completeWithExpression(ExpressionTree expression) {
Preconditions.checkState(this.expression == null);
ExpressionTree result = expression;
if (nestedDimensions != null) {
nestedDimensions.setLastChildType((TypeTree) expression);
result = nestedDimensions;
}
this.expression = result;
return this;
}
use of org.sonar.plugins.java.api.tree.ExpressionTree in project sonar-java by SonarSource.
the class AbsOnNegativeCheck method visitNode.
@Override
public void visitNode(Tree tree) {
if (tree.is(Tree.Kind.METHOD_INVOCATION)) {
MethodInvocationTree methodTree = (MethodInvocationTree) tree;
if (MATH_ABS_METHODS.anyMatch(methodTree)) {
ExpressionTree firstArgument = methodTree.arguments().get(0);
checkForIssue(firstArgument);
}
} else {
ExpressionTree operand = ((UnaryExpressionTree) tree).expression();
checkForIssue(operand);
}
}
use of org.sonar.plugins.java.api.tree.ExpressionTree in project sonar-java by SonarSource.
the class CastArithmeticOperandCheck method visitAssignmentExpression.
@Override
public void visitAssignmentExpression(AssignmentExpressionTree aet) {
if (aet.is(Tree.Kind.ASSIGNMENT)) {
Type varType = aet.symbolType();
ExpressionTree expr = aet.expression();
checkExpression(varType, expr);
}
super.visitAssignmentExpression(aet);
}
use of org.sonar.plugins.java.api.tree.ExpressionTree in project sonar-java by SonarSource.
the class CastArithmeticOperandCheck method checkIntegerDivisionInsideFloatingPointExpression.
private boolean checkIntegerDivisionInsideFloatingPointExpression(BinaryExpressionTree integerDivision) {
Tree parent = integerDivision.parent();
while (parent instanceof ExpressionTree) {
ExpressionTree expressionTree = (ExpressionTree) parent;
if (isFloatingPoint(expressionTree.symbolType())) {
context.reportIssue(this, integerDivision, "Cast one of the operands of this integer division to a \"double\".");
return false;
}
parent = expressionTree.parent();
}
return true;
}
Aggregations