More minor tweaks

This commit is contained in:
Rick Ossendrijver
2023-01-13 10:44:49 +01:00
parent 79b2b51a00
commit a2626ee8bf

View File

@@ -10,6 +10,7 @@ import com.google.errorprone.bugpatterns.BugChecker.MethodTreeMatcher;
import com.google.errorprone.matchers.Description;
import com.google.errorprone.util.ASTHelpers;
import com.sun.source.tree.MethodTree;
import com.sun.tools.javac.code.Symbol;
import org.junit.jupiter.api.Test;
final class ConflictDetectionTest {
@@ -18,28 +19,28 @@ final class ConflictDetectionTest {
CompilationTestHelper.newInstance(RenameBlockerFlagger.class, getClass())
.addSourceLines(
"/A.java",
"import static staticimport.B.foo3t;",
"import static pkg.B.foo3t;",
"",
"class A {",
" private void foo1() {",
" foo3t();",
" }",
"",
" // BUG: Diagnostic contains: [RenameBlockerFlagger] a method named `foo2t` is already defined in",
" // this class or a supertype",
" // BUG: Diagnostic contains: a method named `foo2t` is already defined in this class or a",
" // supertype",
" private void foo2() {}",
"",
" private void foo2t() {}",
"",
" // BUG: Diagnostic contains: [RenameBlockerFlagger] `foo3t` is already statically imported",
" // BUG: Diagnostic contains: `foo3t` is already statically imported",
" private void foo3() {}",
"",
" // BUG: Diagnostic contains: [RenameBlockerFlagger] `int` is not a valid identifier",
" // BUG: Diagnostic contains: `int` is not a valid identifier",
" private void in() {}",
"}")
.addSourceLines(
"/staticimport/B.java",
"package staticimport;",
"/pkg/B.java",
"package pkg;",
"",
"public class B {",
" public static void foo3t() {}",
@@ -47,6 +48,10 @@ final class ConflictDetectionTest {
.doTest();
}
/**
* A {@link BugChecker} that flags method rename blockers found by {@link
* ConflictDetection#findMethodRenameBlocker(Symbol.MethodSymbol, String, VisitorState)}.
*/
@BugPattern(summary = "Flags blockers for renaming methods", severity = ERROR)
public static final class RenameBlockerFlagger extends BugChecker implements MethodTreeMatcher {
private static final long serialVersionUID = 1L;