Created
May 17, 2018 23:30
-
-
Save msridhar/9e5d92774bc1bbe9aa4c589533922b61 to your computer and use it in GitHub Desktop.
Dummy Error Prone check that does extra AST traversals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package testpasses; | |
import com.google.auto.service.AutoService; | |
import com.google.errorprone.BugPattern; | |
import com.google.errorprone.ErrorProneFlags; | |
import com.google.errorprone.VisitorState; | |
import com.google.errorprone.bugpatterns.BugChecker; | |
import com.google.errorprone.matchers.Description; | |
import com.sun.source.tree.CompilationUnitTree; | |
import com.sun.source.util.TreeScanner; | |
import static com.google.errorprone.BugPattern.Category.ONE_OFF; | |
import static com.google.errorprone.BugPattern.SeverityLevel.WARNING; | |
@AutoService(BugChecker.class) | |
@BugPattern( | |
name = "TestPasses", | |
summary = "Testing performance cost of many passes", | |
category = ONE_OFF, | |
severity = WARNING | |
) | |
public class TestPasses extends BugChecker | |
implements BugChecker.CompilationUnitTreeMatcher { | |
final int numScans; | |
public TestPasses() { | |
this(ErrorProneFlags.empty()); | |
} | |
public TestPasses(ErrorProneFlags flags) { | |
numScans = flags.get("TestPasses:NumScans").map(Integer::parseInt).orElse(1); | |
} | |
@Override | |
public Description matchCompilationUnit(CompilationUnitTree tree, | |
VisitorState state) { | |
for (int i = 0; i < numScans; i++) { | |
(new DummyScanner()).scan(tree, null); | |
} | |
return Description.NO_MATCH; | |
} | |
private static class DummyScanner extends TreeScanner<Void, Void> { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment