Skip to content

Commit

Permalink
Update Inliner messaging to mention that the API they're calling is…
Browse files Browse the repository at this point in the history
… deprecated.

PiperOrigin-RevId: 418661407
  • Loading branch information
kluever authored and Error Prone Team committed Dec 28, 2021
1 parent 8bcd7cb commit 8dc4654
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static com.google.errorprone.util.ASTHelpers.enclosingPackage;
import static com.google.errorprone.util.ASTHelpers.getReceiver;
import static com.google.errorprone.util.ASTHelpers.getSymbol;
import static com.google.errorprone.util.ASTHelpers.hasAnnotation;
import static com.google.errorprone.util.ASTHelpers.hasDirectAnnotationWithSimpleName;
import static com.google.errorprone.util.ASTHelpers.stringContainsComments;
import static com.google.errorprone.util.MoreAnnotations.getValue;
Expand Down Expand Up @@ -151,7 +152,7 @@ private Description match(
return Description.NO_MATCH;
}

Api api = Api.create(symbol);
Api api = Api.create(symbol, state);
if (!matchesApiPrefixes(api)) {
return Description.NO_MATCH;
}
Expand Down Expand Up @@ -278,7 +279,7 @@ private Description describe(Tree tree, SuggestedFix fix, Api api) {
abstract static class Api {
private static final Splitter CLASS_NAME_SPLITTER = Splitter.on('.');

static Api create(MethodSymbol method) {
static Api create(MethodSymbol method, VisitorState state) {
String extraMessage = "";
if (hasDirectAnnotationWithSimpleName(method, VALIDATION_DISABLED)) {
Attribute.Compound inlineMeValidationDisabled =
Expand All @@ -293,6 +294,7 @@ static Api create(MethodSymbol method) {
method.getSimpleName().toString(),
enclosingPackage(method).toString(),
method.isConstructor(),
hasAnnotation(method, "java.lang.Deprecated", state),
extraMessage);
}

Expand All @@ -304,10 +306,15 @@ static Api create(MethodSymbol method) {

abstract boolean isConstructor();

abstract boolean isDeprecated();

abstract String extraMessage();

final String message() {
return shortName() + " should be inlined" + extraMessage();
return shortName()
+ (isDeprecated() ? " is deprecated and" : "")
+ " should be inlined"
+ extraMessage();
}

/** Returns {@code FullyQualifiedClassName#methodName}. */
Expand Down

0 comments on commit 8dc4654

Please sign in to comment.