Skip to content

Commit

Permalink
Add Matchers to StaticImport check
Browse files Browse the repository at this point in the history
  • Loading branch information
oxkitsune committed Aug 17, 2022
1 parent c39d125 commit 40ec911
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public final class StaticImport extends BugChecker implements MemberSelectTreeMa
"com.google.errorprone.BugPattern.LinkType",
"com.google.errorprone.BugPattern.SeverityLevel",
"com.google.errorprone.BugPattern.StandardTags",
"com.google.errorprone.matchers.Matchers",
"com.google.errorprone.refaster.ImportPolicy",
"com.mongodb.client.model.Accumulators",
"com.mongodb.client.model.Aggregates",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ void identification() {
"import com.google.common.collect.ImmutableMap;",
"import com.google.common.collect.ImmutableMultiset;",
"import com.google.common.collect.ImmutableSet;",
"import com.google.errorprone.matchers.Matcher;",
"import com.google.errorprone.matchers.Matchers;",
"import com.google.errorprone.refaster.ImportPolicy;",
"import com.google.errorprone.refaster.annotation.UseImportPolicy;",
"import com.sun.source.tree.AnnotationTree;",
"import java.nio.charset.StandardCharsets;",
"import java.time.ZoneOffset;",
"import java.util.Optional;",
Expand All @@ -57,6 +60,9 @@ void identification() {
"import org.springframework.http.MediaType;",
"",
"class A {",
" // BUG: Diagnostic contains:",
" private static final Matcher<AnnotationTree> FOO = Matchers.isType(\"org.junit.jupiter.api.Test\");",
"",
" void m() {",
" // BUG: Diagnostic contains:",
" ImmutableMap.toImmutableMap(v -> v, v -> v);",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package tech.picnic.errorprone.refaster.util;

import static com.google.errorprone.matchers.Matchers.isArrayType;

import com.google.errorprone.VisitorState;
import com.google.errorprone.matchers.Matcher;
import com.google.errorprone.matchers.Matchers;
import com.sun.source.tree.ExpressionTree;

/** A matcher of array-typed expressions, for use with Refaster's {@code @Matches} annotation. */
public final class IsArray implements Matcher<ExpressionTree> {
private static final long serialVersionUID = 1L;
private static final Matcher<ExpressionTree> DELEGATE = Matchers.isArrayType();
private static final Matcher<ExpressionTree> DELEGATE = isArrayType();

@Override
public boolean matches(ExpressionTree tree, VisitorState state) {
Expand Down

0 comments on commit 40ec911

Please sign in to comment.