|
17 | 17 | package com.google.errorprone.bugpatterns.nullness; |
18 | 18 |
|
19 | 19 | import static com.google.errorprone.BugPattern.SeverityLevel.WARNING; |
| 20 | +import static com.google.errorprone.dataflow.nullnesspropagation.NullnessAnnotations.annotationsAreAmbiguous; |
| 21 | +import static com.google.errorprone.dataflow.nullnesspropagation.NullnessAnnotations.annotationsRelevantToNullness; |
20 | 22 | import static com.google.errorprone.matchers.Description.NO_MATCH; |
21 | 23 | import static com.google.errorprone.util.ASTHelpers.getSymbol; |
22 | 24 | import static com.google.errorprone.util.ASTHelpers.getType; |
| 25 | +import static java.util.stream.Collectors.joining; |
23 | 26 |
|
24 | 27 | import com.google.common.collect.ImmutableSet; |
25 | 28 | import com.google.errorprone.BugPattern; |
|
28 | 31 | import com.google.errorprone.bugpatterns.BugChecker.AnnotatedTypeTreeMatcher; |
29 | 32 | import com.google.errorprone.bugpatterns.BugChecker.MethodTreeMatcher; |
30 | 33 | import com.google.errorprone.bugpatterns.BugChecker.VariableTreeMatcher; |
31 | | -import com.google.errorprone.dataflow.nullnesspropagation.NullnessAnnotations; |
32 | 34 | import com.google.errorprone.matchers.Description; |
33 | 35 | import com.sun.source.tree.AnnotatedTypeTree; |
34 | 36 | import com.sun.source.tree.MethodTree; |
@@ -75,9 +77,14 @@ private Description match(Tree tree, Symbol symbol, Type type) { |
75 | 77 | } |
76 | 78 |
|
77 | 79 | private Description match(Tree tree, Collection<? extends AnnotationMirror> annotations) { |
78 | | - if (NullnessAnnotations.annotationsAreAmbiguous(annotations)) { |
79 | | - return describeMatch(tree); |
| 80 | + if (!annotationsAreAmbiguous(annotations)) { |
| 81 | + return NO_MATCH; |
80 | 82 | } |
81 | | - return NO_MATCH; |
| 83 | + return buildDescription(tree) |
| 84 | + .setMessage( |
| 85 | + annotationsRelevantToNullness(annotations).stream() |
| 86 | + .map(a -> a.getAnnotationType().asElement().toString()) |
| 87 | + .collect(joining(", ", "This type use has conflicting nullness annotations: ", ""))) |
| 88 | + .build(); |
82 | 89 | } |
83 | 90 | } |
0 commit comments