Skip to content

Commit

Permalink
Suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan202 authored and rickie committed Jun 19, 2023
1 parent e0cd928 commit 2d859ec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 2d859ec

Please sign in to comment.