Search in sources :

Example 1 with CheckerDispatcher

use of org.sonar.java.se.CheckerDispatcher in project sonar-java by SonarSource.

the class DebugMethodYieldsOnInvocationsCheck method reportAll.

private void reportAll(CheckerContext context) {
    CheckerDispatcher checkerDispatcher = (CheckerDispatcher) context;
    methodInvocations.pop().stream().filter(mit -> mit.symbol().isMethodSymbol()).forEach(mit -> reportYields(mit, checkerDispatcher));
}
Also used : ProgramState(org.sonar.java.se.ProgramState) Priority(org.sonar.check.Priority) CheckerDispatcher(org.sonar.java.se.CheckerDispatcher) Set(java.util.Set) Tree(org.sonar.plugins.java.api.tree.Tree) Deque(java.util.Deque) JavaFileScannerContext(org.sonar.plugins.java.api.JavaFileScannerContext) ArrayList(java.util.ArrayList) CheckerContext(org.sonar.java.se.CheckerContext) ExpressionTree(org.sonar.plugins.java.api.tree.ExpressionTree) MethodInvocationTree(org.sonar.plugins.java.api.tree.MethodInvocationTree) List(java.util.List) CFG(org.sonar.java.cfg.CFG) Flow(org.sonar.java.se.Flow) SECheck(org.sonar.java.se.checks.SECheck) MemberSelectExpressionTree(org.sonar.plugins.java.api.tree.MemberSelectExpressionTree) DebugCheck(org.sonar.java.DebugCheck) MethodBehavior(org.sonar.java.se.xproc.MethodBehavior) Rule(org.sonar.check.Rule) LinkedList(java.util.LinkedList) IdentifierTree(org.sonar.plugins.java.api.tree.IdentifierTree) Collections(java.util.Collections) Symbol(org.sonar.plugins.java.api.semantic.Symbol) MethodTree(org.sonar.plugins.java.api.tree.MethodTree) CheckerDispatcher(org.sonar.java.se.CheckerDispatcher)

Example 2 with CheckerDispatcher

use of org.sonar.java.se.CheckerDispatcher in project sonar-java by SonarSource.

the class DebugMethodYieldsCheck method checkEndOfExecution.

@Override
public void checkEndOfExecution(CheckerContext context) {
    MethodBehavior mb = ((CheckerDispatcher) context).methodBehavior();
    IdentifierTree methodName = methodNames.pop();
    if (mb != null) {
        reportIssue(methodName, String.format("Method '%s' has %d method yields.", methodName.name(), mb.yields().size()), flowFromYield(mb, methodName));
    }
}
Also used : CheckerDispatcher(org.sonar.java.se.CheckerDispatcher) MethodBehavior(org.sonar.java.se.xproc.MethodBehavior) IdentifierTree(org.sonar.plugins.java.api.tree.IdentifierTree)

Aggregations

CheckerDispatcher (org.sonar.java.se.CheckerDispatcher)2 MethodBehavior (org.sonar.java.se.xproc.MethodBehavior)2 IdentifierTree (org.sonar.plugins.java.api.tree.IdentifierTree)2 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Deque (java.util.Deque)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Set (java.util.Set)1 Priority (org.sonar.check.Priority)1 Rule (org.sonar.check.Rule)1 DebugCheck (org.sonar.java.DebugCheck)1 CFG (org.sonar.java.cfg.CFG)1 CheckerContext (org.sonar.java.se.CheckerContext)1 Flow (org.sonar.java.se.Flow)1 ProgramState (org.sonar.java.se.ProgramState)1 SECheck (org.sonar.java.se.checks.SECheck)1 JavaFileScannerContext (org.sonar.plugins.java.api.JavaFileScannerContext)1 Symbol (org.sonar.plugins.java.api.semantic.Symbol)1 ExpressionTree (org.sonar.plugins.java.api.tree.ExpressionTree)1