use of org.sonar.plugins.java.api.tree.ExpressionTree in project sonar-java by SonarSource.
the class AssignmentInSubExpressionCheck method skipChainedAssignments.
private ExpressionTree skipChainedAssignments(ExpressionTree expressionTree) {
ExpressionTree tree = ExpressionUtils.skipParentheses(expressionTree);
while (tree instanceof AssignmentExpressionTree) {
AssignmentExpressionTree assignmentExpressionTree = (AssignmentExpressionTree) tree;
scan(assignmentExpressionTree.variable());
tree = ExpressionUtils.skipParentheses(assignmentExpressionTree.expression());
}
return tree;
}
use of org.sonar.plugins.java.api.tree.ExpressionTree in project sonar-java by SonarSource.
the class AssignmentInSubExpressionCheck method visitVariable.
@Override
public void visitVariable(VariableTree tree) {
ExpressionTree initializer = tree.initializer();
if (initializer != null) {
ExpressionTree expressionTree = skipChainedAssignments(initializer);
scan(expressionTree);
}
}
use of org.sonar.plugins.java.api.tree.ExpressionTree in project sonar-java by SonarSource.
the class AvoidDESCheck method onMethodInvocationFound.
@Override
protected void onMethodInvocationFound(MethodInvocationTree mit) {
ExpressionTree firstArg = mit.arguments().get(0);
ExpressionTree defaultPropertyValue = JavaPropertiesHelper.retrievedPropertyDefaultValue(firstArg);
if (defaultPropertyValue == null) {
defaultPropertyValue = firstArg;
}
if (defaultPropertyValue.is(Tree.Kind.STRING_LITERAL)) {
checkIssue(firstArg, (LiteralTree) defaultPropertyValue);
}
}
use of org.sonar.plugins.java.api.tree.ExpressionTree in project sonar-java by SonarSource.
the class SyntaxTreeDebug method argumentsString.
private static String argumentsString(Arguments syntaxNode) {
StringBuilder buffer = new StringBuilder();
boolean first = true;
for (ExpressionTree expressionTree : syntaxNode) {
if (first) {
first = false;
} else {
buffer.append(',');
}
buffer.append(toString(expressionTree));
}
return buffer.toString();
}
use of org.sonar.plugins.java.api.tree.ExpressionTree in project sonar-java by SonarSource.
the class SyntaxTreeDebug method newInstanceString.
private static String newInstanceString(NewClassTree syntaxNode) {
StringBuilder buffer = new StringBuilder("new ");
buffer.append(syntaxNode.identifier().toString());
buffer.append('(');
boolean first = true;
for (ExpressionTree argument : syntaxNode.arguments()) {
if (first) {
first = false;
} else {
buffer.append(',');
}
buffer.append(toString(argument));
}
buffer.append(')');
return buffer.toString();
}
Aggregations