use of org.sonar.plugins.java.api.tree.ClassTree in project sonar-java by SonarSource.
the class NonNullSetToNullCheck method checkEndOfExecutionPath.
@Override
public void checkEndOfExecutionPath(CheckerContext context, ConstraintManager constraintManager) {
if (methodTree.is(Tree.Kind.CONSTRUCTOR) && !isDefaultConstructorForJpa(methodTree) && !callsThisConstructor(methodTree) && !exitingWithException(context)) {
ClassTree classTree = (ClassTree) methodTree.parent();
classTree.members().stream().filter(m -> m.is(Tree.Kind.VARIABLE)).map(m -> (VariableTree) m).filter(v -> v.initializer() == null).forEach(v -> checkVariable(context, methodTree, v.symbol()));
}
}
use of org.sonar.plugins.java.api.tree.ClassTree in project sonar-java by SonarSource.
the class CallSuperMethodFromInnerClassCheck method visitNode.
@Override
public void visitNode(Tree tree) {
ClassTree classTree = (ClassTree) tree;
Symbol.TypeSymbol classSymbol = classTree.symbol();
if (classSymbol != null && isInnerClass(classSymbol) && !extendsOuterClass(classSymbol)) {
classTree.accept(new MethodInvocationVisitor(classSymbol));
}
}
use of org.sonar.plugins.java.api.tree.ClassTree in project sonar-java by SonarSource.
the class LeftCurlyBraceBaseTreeVisitor method visitNewClass.
@Override
public void visitNewClass(NewClassTree tree) {
ClassTree classBody = tree.classBody();
if (classBody != null && tree.arguments().closeParenToken() != null) {
checkTokens(tree.arguments().closeParenToken(), classBody.openBraceToken());
}
super.visitNewClass(tree);
}
use of org.sonar.plugins.java.api.tree.ClassTree in project sonar-java by SonarSource.
the class LeftCurlyBraceBaseTreeVisitor method visitEnumConstant.
@Override
public void visitEnumConstant(EnumConstantTree tree) {
NewClassTree initializer = tree.initializer();
ClassTree classBody = initializer.classBody();
if (classBody != null) {
SyntaxToken openBraceToken = classBody.openBraceToken();
if (initializer.arguments().closeParenToken() != null) {
checkTokens(initializer.arguments().closeParenToken(), openBraceToken);
} else {
checkTokens(tree.simpleName().identifierToken(), openBraceToken);
}
}
super.visitEnumConstant(tree);
}
use of org.sonar.plugins.java.api.tree.ClassTree in project sonar-java by SonarSource.
the class MembersDifferOnlyByCapitalizationCheck method visitNode.
@Override
public void visitNode(Tree tree) {
if (!hasSemantic()) {
return;
}
ClassTree classTree = (ClassTree) tree;
List<Symbol> allMembers = retrieveMembers(classTree.symbol());
Multimap<String, Symbol> membersByName = sortByName(allMembers);
for (Tree member : classTree.members()) {
if (member.is(Tree.Kind.METHOD)) {
MethodTree methodTree = (MethodTree) member;
checkForIssue(methodTree.symbol(), methodTree.simpleName(), membersByName);
} else if (member.is(Tree.Kind.VARIABLE)) {
VariableTree variableTree = (VariableTree) member;
checkForIssue(variableTree.symbol(), variableTree.simpleName(), membersByName);
}
}
}
Aggregations