Search in sources :

Example 1 with CONSTRUCTOR

use of org.sonar.plugins.java.api.tree.Tree.Kind.CONSTRUCTOR in project sonar-java by SonarSource.

the class TwoLocksWaitCheck method visitNode.

@Override
public void visitNode(Tree tree) {
    if (!hasSemantic()) {
        return;
    }
    if (tree.is(METHOD, CONSTRUCTOR)) {
        MethodTree methodTree = (MethodTree) tree;
        int initialCounter = findModifier(methodTree.modifiers(), SYNCHRONIZED).map(m -> 1).orElse(0);
        synchronizedStack.push(new Counter(initialCounter));
        findWaitInvocation(methodTree);
    }
}
Also used : SYNCHRONIZED(org.sonar.plugins.java.api.tree.Modifier.SYNCHRONIZED) BaseTreeVisitor(org.sonar.plugins.java.api.tree.BaseTreeVisitor) Tree(org.sonar.plugins.java.api.tree.Tree) METHOD(org.sonar.plugins.java.api.tree.Tree.Kind.METHOD) SynchronizedStatementTree(org.sonar.plugins.java.api.tree.SynchronizedStatementTree) Deque(java.util.Deque) JavaFileScannerContext(org.sonar.plugins.java.api.JavaFileScannerContext) Collectors(java.util.stream.Collectors) MethodInvocationTree(org.sonar.plugins.java.api.tree.MethodInvocationTree) LambdaExpressionTree(org.sonar.plugins.java.api.tree.LambdaExpressionTree) List(java.util.List) Stream(java.util.stream.Stream) ImmutableList(com.google.common.collect.ImmutableList) MethodMatcher(org.sonar.java.matcher.MethodMatcher) ClassTree(org.sonar.plugins.java.api.tree.ClassTree) IssuableSubscriptionVisitor(org.sonar.plugins.java.api.IssuableSubscriptionVisitor) Optional(java.util.Optional) SyntaxToken(org.sonar.plugins.java.api.tree.SyntaxToken) CONSTRUCTOR(org.sonar.plugins.java.api.tree.Tree.Kind.CONSTRUCTOR) Rule(org.sonar.check.Rule) LinkedList(java.util.LinkedList) ModifiersUtils.findModifier(org.sonar.java.model.ModifiersUtils.findModifier) MethodTree(org.sonar.plugins.java.api.tree.MethodTree) MethodTree(org.sonar.plugins.java.api.tree.MethodTree)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 Deque (java.util.Deque)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Rule (org.sonar.check.Rule)1 MethodMatcher (org.sonar.java.matcher.MethodMatcher)1 ModifiersUtils.findModifier (org.sonar.java.model.ModifiersUtils.findModifier)1 IssuableSubscriptionVisitor (org.sonar.plugins.java.api.IssuableSubscriptionVisitor)1 JavaFileScannerContext (org.sonar.plugins.java.api.JavaFileScannerContext)1 BaseTreeVisitor (org.sonar.plugins.java.api.tree.BaseTreeVisitor)1 ClassTree (org.sonar.plugins.java.api.tree.ClassTree)1 LambdaExpressionTree (org.sonar.plugins.java.api.tree.LambdaExpressionTree)1 MethodInvocationTree (org.sonar.plugins.java.api.tree.MethodInvocationTree)1 MethodTree (org.sonar.plugins.java.api.tree.MethodTree)1 SYNCHRONIZED (org.sonar.plugins.java.api.tree.Modifier.SYNCHRONIZED)1 SynchronizedStatementTree (org.sonar.plugins.java.api.tree.SynchronizedStatementTree)1 SyntaxToken (org.sonar.plugins.java.api.tree.SyntaxToken)1