Skip to content

Commit

Permalink
Classpath suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan202 committed Jun 30, 2022
1 parent 19569f9 commit 7ba62d5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion error-prone-contrib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@
</dependency>
<dependency>
<groupId>org.immutables</groupId>
<artifactId>value</artifactId>
<artifactId>value-annotations</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
import com.google.errorprone.matchers.Matcher;
import com.sun.source.tree.MethodTree;
import com.sun.source.tree.Tree;
import org.immutables.value.Value.Immutable;
import org.immutables.value.Value.Modifiable;
import org.immutables.value.Value.NaturalOrder;

/**
* A {@link BugChecker} which flags methods with return type {@link
Expand All @@ -43,15 +40,18 @@ public final class MissingImmutableSortedSetDefaultCheck extends BugChecker
implements MethodTreeMatcher {
private static final long serialVersionUID = 1L;
private static final Matcher<Tree> ENCLOSING_IS_MODIFIABLE_OR_IMMUTABLES =
enclosingClass(anyOf(hasAnnotation(Immutable.class), hasAnnotation(Modifiable.class)));
enclosingClass(
anyOf(
hasAnnotation("org.immutables.value.Value.Immutable"),
hasAnnotation("org.immutables.value.Value.Modifiable")));
private static final Matcher<MethodTree> RETURNS_IMMUTABLE_SORTED_SET =
methodReturns(isSameType(ImmutableSortedSet.class));

@Override
public Description matchMethod(MethodTree tree, VisitorState state) {
if (!RETURNS_IMMUTABLE_SORTED_SET.matches(tree, state)
|| !ENCLOSING_IS_MODIFIABLE_OR_IMMUTABLES.matches(tree, state)
|| hasAnnotation(NaturalOrder.class).matches(tree, state)) {
|| hasAnnotation("org.immutables.value.Value.NaturalOrder").matches(tree, state)) {
return Description.NO_MATCH;
}

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@
</dependency>
<dependency>
<groupId>org.immutables</groupId>
<artifactId>value</artifactId>
<version>2.8.2</version>
<artifactId>value-annotations</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>org.junit</groupId>
Expand Down

0 comments on commit 7ba62d5

Please sign in to comment.