Search in sources :

Example 1 with ExplodedGraphWalker

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

the class DebugCheckTestUtils method verifyIssuesWithMaxSteps.

static void verifyIssuesWithMaxSteps(String sourcefile, SECheck check, int maxSteps) {
    BehaviorCache behaviorCache = new BehaviorCache(new SquidClassLoader(new ArrayList<>()));
    SymbolicExecutionVisitor sev = new SymbolicExecutionVisitor(Collections.singletonList(check), behaviorCache) {

        @Override
        protected ExplodedGraphWalker getWalker() {
            return new ExplodedGraphWalker(Collections.singletonList(check), behaviorCache, (SemanticModel) context.getSemanticModel()) {

                @Override
                protected int maxSteps() {
                    return maxSteps;
                }
            };
        }

        @Override
        public void scanFile(JavaFileScannerContext context) {
            super.scanFile(context);
            // the check has been executed, but we still need to call the scan manually to report the issues
            check.scanFile(context);
        }
    };
    JavaCheckVerifier.verify(sourcefile, sev);
}
Also used : ExplodedGraphWalker(org.sonar.java.se.ExplodedGraphWalker) JavaFileScannerContext(org.sonar.plugins.java.api.JavaFileScannerContext) ArrayList(java.util.ArrayList) BehaviorCache(org.sonar.java.se.xproc.BehaviorCache) SymbolicExecutionVisitor(org.sonar.java.se.SymbolicExecutionVisitor) SquidClassLoader(org.sonar.java.bytecode.loader.SquidClassLoader)

Aggregations

ArrayList (java.util.ArrayList)1 SquidClassLoader (org.sonar.java.bytecode.loader.SquidClassLoader)1 ExplodedGraphWalker (org.sonar.java.se.ExplodedGraphWalker)1 SymbolicExecutionVisitor (org.sonar.java.se.SymbolicExecutionVisitor)1 BehaviorCache (org.sonar.java.se.xproc.BehaviorCache)1 JavaFileScannerContext (org.sonar.plugins.java.api.JavaFileScannerContext)1