From cd2118b5f62665431c98b2943a49c4eb42cfe674 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Mon, 4 Jul 2022 06:21:30 +0200 Subject: [PATCH] Suggestions --- .../google/errorprone/refaster/UFreeIdentTest.java | 14 ++++++-------- .../google/errorprone/refaster/URepeatedTest.java | 14 ++++++-------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/core/src/test/java/com/google/errorprone/refaster/UFreeIdentTest.java b/core/src/test/java/com/google/errorprone/refaster/UFreeIdentTest.java index ad153d89c7e1..1e0840459b88 100644 --- a/core/src/test/java/com/google/errorprone/refaster/UFreeIdentTest.java +++ b/core/src/test/java/com/google/errorprone/refaster/UFreeIdentTest.java @@ -25,9 +25,9 @@ import com.google.errorprone.CompilationTestHelper; import com.google.errorprone.VisitorState; import com.google.errorprone.bugpatterns.BugChecker; -import com.google.errorprone.bugpatterns.BugChecker.ExpressionStatementTreeMatcher; +import com.google.errorprone.bugpatterns.BugChecker.MethodInvocationTreeMatcher; import com.google.errorprone.matchers.Description; -import com.sun.source.tree.ExpressionStatementTree; +import com.sun.source.tree.MethodInvocationTree; import com.sun.tools.javac.util.Context; import org.junit.Test; import org.junit.runner.RunWith; @@ -66,16 +66,14 @@ public void binds() { summary = "Verify that unifying the expression results in the correct binding", explanation = "For test purposes only", severity = SUGGESTION) - public static class UnificationChecker extends BugChecker - implements ExpressionStatementTreeMatcher { + public static class UnificationChecker extends BugChecker implements MethodInvocationTreeMatcher { @Override - public Description matchExpressionStatement(ExpressionStatementTree tree, VisitorState state) { + public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState state) { Unifier unifier = new Unifier(new Context()); UFreeIdent ident = UFreeIdent.create("foo"); - assertThat(ident.unify(tree.getExpression(), unifier)).isNotNull(); - assertThat(unifier.getBindings()) - .containsExactly(new UFreeIdent.Key("foo"), tree.getExpression()); + assertThat(ident.unify(tree, unifier)).isNotNull(); + assertThat(unifier.getBindings()).containsExactly(new UFreeIdent.Key("foo"), tree); return Description.NO_MATCH; } diff --git a/core/src/test/java/com/google/errorprone/refaster/URepeatedTest.java b/core/src/test/java/com/google/errorprone/refaster/URepeatedTest.java index 9e09e2540654..c73a87d0a973 100644 --- a/core/src/test/java/com/google/errorprone/refaster/URepeatedTest.java +++ b/core/src/test/java/com/google/errorprone/refaster/URepeatedTest.java @@ -25,9 +25,9 @@ import com.google.errorprone.CompilationTestHelper; import com.google.errorprone.VisitorState; import com.google.errorprone.bugpatterns.BugChecker; -import com.google.errorprone.bugpatterns.BugChecker.ExpressionStatementTreeMatcher; +import com.google.errorprone.bugpatterns.BugChecker.MethodInvocationTreeMatcher; import com.google.errorprone.matchers.Description; -import com.sun.source.tree.ExpressionStatementTree; +import com.sun.source.tree.MethodInvocationTree; import com.sun.tools.javac.util.Context; import org.junit.Test; import org.junit.runner.RunWith; @@ -56,16 +56,14 @@ public void unifies() { summary = "Verify that unifying the expression results in the correct binding", explanation = "For test purposes only", severity = SUGGESTION) - public static class UnificationChecker extends BugChecker - implements ExpressionStatementTreeMatcher { + public static class UnificationChecker extends BugChecker implements MethodInvocationTreeMatcher { @Override - public Description matchExpressionStatement(ExpressionStatementTree tree, VisitorState state) { + public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState state) { Unifier unifier = new Unifier(new Context()); URepeated ident = URepeated.create("foo", UFreeIdent.create("foo")); - assertThat(ident.unify(tree.getExpression(), unifier)).isNotNull(); - assertThat(unifier.getBindings()) - .containsExactly(new UFreeIdent.Key("foo"), tree.getExpression()); + assertThat(ident.unify(tree, unifier)).isNotNull(); + assertThat(unifier.getBindings()).containsExactly(new UFreeIdent.Key("foo"), tree); return Description.NO_MATCH; }