[KeepAnno] Mark deprecated methods with descriptive links

Bug: b/248408342
Change-Id: I1f46fa8b6d76b501bc68e8066a0e0c1564553334
diff --git a/src/keepanno/java/com/android/tools/r8/keepanno/annotations/KeepBinding.java b/src/keepanno/java/com/android/tools/r8/keepanno/annotations/KeepBinding.java
index 0e79f51..36df829 100644
--- a/src/keepanno/java/com/android/tools/r8/keepanno/annotations/KeepBinding.java
+++ b/src/keepanno/java/com/android/tools/r8/keepanno/annotations/KeepBinding.java
@@ -202,8 +202,6 @@
    * <p>The pattern is exclusive in that it does not match classes that are instances of the
    * pattern, but only those that are instances of classes that are subclasses of the pattern.
    *
-   * <p>This property is deprecated, use instanceOfClassName instead.
-   *
    * <p>Mutually exclusive with the following other properties defining instance-of:
    *
    * <ul>
@@ -218,7 +216,9 @@
    * <p>If none are specified the default is to match any class instance.
    *
    * @return The class name that defines what the class must extend.
+   * @deprecated This property is deprecated, use {@link #instanceOfClassName} instead.
    */
+  @Deprecated
   String extendsClassName() default "";
 
   /**
@@ -227,8 +227,6 @@
    * <p>The pattern is exclusive in that it does not match classes that are instances of the
    * pattern, but only those that are instances of classes that are subclasses of the pattern.
    *
-   * <p>This property is deprecated, use instanceOfClassConstant instead.
-   *
    * <p>Mutually exclusive with the following other properties defining instance-of:
    *
    * <ul>
@@ -243,7 +241,9 @@
    * <p>If none are specified the default is to match any class instance.
    *
    * @return The class constant that defines what the class must extend.
+   * @deprecated This property is deprecated, use {@link #instanceOfClassConstant} instead.
    */
+  @Deprecated
   Class<?> extendsClassConstant() default Object.class;
 
   /**
diff --git a/src/keepanno/java/com/android/tools/r8/keepanno/annotations/KeepCondition.java b/src/keepanno/java/com/android/tools/r8/keepanno/annotations/KeepCondition.java
index ecdb94e..d26fd2c 100644
--- a/src/keepanno/java/com/android/tools/r8/keepanno/annotations/KeepCondition.java
+++ b/src/keepanno/java/com/android/tools/r8/keepanno/annotations/KeepCondition.java
@@ -174,8 +174,6 @@
    * <p>The pattern is exclusive in that it does not match classes that are instances of the
    * pattern, but only those that are instances of classes that are subclasses of the pattern.
    *
-   * <p>This property is deprecated, use instanceOfClassName instead.
-   *
    * <p>Mutually exclusive with the following other properties defining instance-of:
    *
    * <ul>
@@ -190,7 +188,9 @@
    * <p>If none are specified the default is to match any class instance.
    *
    * @return The class name that defines what the class must extend.
+   * @deprecated This property is deprecated, use {@link #instanceOfClassName} instead.
    */
+  @Deprecated
   String extendsClassName() default "";
 
   /**
@@ -199,8 +199,6 @@
    * <p>The pattern is exclusive in that it does not match classes that are instances of the
    * pattern, but only those that are instances of classes that are subclasses of the pattern.
    *
-   * <p>This property is deprecated, use instanceOfClassConstant instead.
-   *
    * <p>Mutually exclusive with the following other properties defining instance-of:
    *
    * <ul>
@@ -215,7 +213,9 @@
    * <p>If none are specified the default is to match any class instance.
    *
    * @return The class constant that defines what the class must extend.
+   * @deprecated This property is deprecated, use {@link #instanceOfClassConstant} instead.
    */
+  @Deprecated
   Class<?> extendsClassConstant() default Object.class;
 
   /**
diff --git a/src/keepanno/java/com/android/tools/r8/keepanno/annotations/KeepTarget.java b/src/keepanno/java/com/android/tools/r8/keepanno/annotations/KeepTarget.java
index 3b80210..9e92947 100644
--- a/src/keepanno/java/com/android/tools/r8/keepanno/annotations/KeepTarget.java
+++ b/src/keepanno/java/com/android/tools/r8/keepanno/annotations/KeepTarget.java
@@ -218,8 +218,6 @@
    * <p>The pattern is exclusive in that it does not match classes that are instances of the
    * pattern, but only those that are instances of classes that are subclasses of the pattern.
    *
-   * <p>This property is deprecated, use instanceOfClassName instead.
-   *
    * <p>Mutually exclusive with the following other properties defining instance-of:
    *
    * <ul>
@@ -234,7 +232,9 @@
    * <p>If none are specified the default is to match any class instance.
    *
    * @return The class name that defines what the class must extend.
+   * @deprecated This property is deprecated, use {@link #instanceOfClassName} instead.
    */
+  @Deprecated
   String extendsClassName() default "";
 
   /**
@@ -243,8 +243,6 @@
    * <p>The pattern is exclusive in that it does not match classes that are instances of the
    * pattern, but only those that are instances of classes that are subclasses of the pattern.
    *
-   * <p>This property is deprecated, use instanceOfClassConstant instead.
-   *
    * <p>Mutually exclusive with the following other properties defining instance-of:
    *
    * <ul>
@@ -259,7 +257,9 @@
    * <p>If none are specified the default is to match any class instance.
    *
    * @return The class constant that defines what the class must extend.
+   * @deprecated This property is deprecated, use {@link #instanceOfClassConstant} instead.
    */
+  @Deprecated
   Class<?> extendsClassConstant() default Object.class;
 
   /**
diff --git a/src/test/java/com/android/tools/r8/keepanno/utils/DocPrinterBase.java b/src/test/java/com/android/tools/r8/keepanno/utils/DocPrinterBase.java
index 7a9b073..e83aed8 100644
--- a/src/test/java/com/android/tools/r8/keepanno/utils/DocPrinterBase.java
+++ b/src/test/java/com/android/tools/r8/keepanno/utils/DocPrinterBase.java
@@ -14,12 +14,13 @@
 
   private String title = null;
   private String returnDesc = null;
+  private String deprecatedDesc = null;
   private final List<String> additionalLines = new ArrayList<>();
 
   public abstract T self();
 
   private boolean isEmptyOrJustTitle() {
-    return returnDesc == null && additionalLines.isEmpty();
+    return returnDesc == null && deprecatedDesc == null && additionalLines.isEmpty();
   }
 
   public T clearDocLines() {
@@ -39,6 +40,15 @@
     return self();
   }
 
+  public boolean isDeprecated() {
+    return deprecatedDesc != null;
+  }
+
+  public T setDeprecated(String desc) {
+    deprecatedDesc = desc;
+    return self();
+  }
+
   public T addParagraph(String... lines) {
     return addParagraph(Arrays.asList(lines));
   }
@@ -96,6 +106,9 @@
     if (returnDesc != null) {
       println.accept(" * @return " + returnDesc);
     }
+    if (deprecatedDesc != null) {
+      println.accept(" * @deprecated " + deprecatedDesc);
+    }
     println.accept(" */");
   }
 }
diff --git a/src/test/java/com/android/tools/r8/keepanno/utils/KeepItemAnnotationGenerator.java b/src/test/java/com/android/tools/r8/keepanno/utils/KeepItemAnnotationGenerator.java
index 5ef1f58..83d0aff 100644
--- a/src/test/java/com/android/tools/r8/keepanno/utils/KeepItemAnnotationGenerator.java
+++ b/src/test/java/com/android/tools/r8/keepanno/utils/KeepItemAnnotationGenerator.java
@@ -72,6 +72,9 @@
 
     void generate(Generator generator) {
       printDoc(generator::println);
+      if (isDeprecated()) {
+        generator.println("@Deprecated");
+      }
       if (valueDefault == null) {
         generator.println(valueType + " " + name + "();");
       } else {
@@ -472,7 +475,8 @@
                   + INSTANCE_OF_GROUP
                   + " pattern as classes extending the fully qualified class name.")
           .addParagraph(getInstanceOfExclusiveDoc())
-          .addParagraph("This property is deprecated, use instanceOfClassName instead.")
+          .setDeprecated(
+              "This property is deprecated, use " + docLink(instanceOfClassName()) + " instead.")
           .setDocReturn("The class name that defines what the class must extend.")
           .defaultEmptyString();
     }
@@ -484,7 +488,10 @@
                   + INSTANCE_OF_GROUP
                   + " pattern as classes extending the referenced Class constant.")
           .addParagraph(getInstanceOfExclusiveDoc())
-          .addParagraph("This property is deprecated, use instanceOfClassConstant instead.")
+          .setDeprecated(
+              "This property is deprecated, use "
+                  + docLink(instanceOfClassConstant())
+                  + " instead.")
           .setDocReturn("The class constant that defines what the class must extend.")
           .defaultObjectClass();
     }
@@ -963,6 +970,10 @@
       return "{@link " + simpleName(clazz) + "}";
     }
 
+    private String docLink(GroupMember member) {
+      return "{@link #" + member.name + "}";
+    }
+
     private String docLink(KeepItemKind kind) {
       return "{@link KeepItemKind#" + kind.name() + "}";
     }