Revert "Automatic documentation for "@Column" annotation."
This reverts commit 6c7fb4376706e37f4196378e4cb99fe702aa22de.
Reason for revert: Master is broken; not clear if/how this CL is to blame but since it's not needed immediately backing out right now in case its involved
Change-Id: I2048e28e515c42bf36d4386acc48b060ad9afb8e
diff --git a/src/main/java/com/android/tools/metalava/DocAnalyzer.kt b/src/main/java/com/android/tools/metalava/DocAnalyzer.kt
index 77ff105..c255092 100644
--- a/src/main/java/com/android/tools/metalava/DocAnalyzer.kt
+++ b/src/main/java/com/android/tools/metalava/DocAnalyzer.kt
@@ -206,7 +206,6 @@
"androidx.annotation.StringDef" -> handleTypeDef(annotation, item)
"android.annotation.RequiresFeature" -> handleRequiresFeature(annotation, item)
"androidx.annotation.RequiresApi" -> handleRequiresApi(annotation, item)
- "android.provider.Column" -> handleColumn(annotation, item)
"kotlin.Deprecated" -> handleKotlinDeprecation(annotation, item)
}
@@ -485,48 +484,6 @@
addApiLevelDocumentation(level, item)
}
}
-
- private fun handleColumn(
- annotation: AnnotationItem,
- item: Item
- ) {
- val value = annotation.findAttribute("value")?.leafValues()?.firstOrNull() ?: return
- val readOnly = annotation.findAttribute("readOnly")?.leafValues()?.firstOrNull()?.value() == true
- val sb = StringBuilder(100)
- val resolved = value.resolve()
- val field = resolved as? FieldItem
- sb.append("This constant represents a column name that can be used with a ")
- sb.append("{@link android.content.ContentProvider}")
- sb.append(" through a ")
- sb.append("{@link android.content.ContentValues}")
- sb.append(" or ")
- sb.append("{@link android.database.Cursor}")
- sb.append(" object. The values stored in this column are ")
- sb.append("")
- if (field == null) {
- reporter.report(
- Errors.MISSING_COLUMN, item,
- "Cannot find feature field for $value required by $item (may be hidden or removed)"
- )
- sb.append("{@link ${value.toSource()}}")
- } else {
- if (filterReference.test(field)) {
- sb.append("{@link ${field.containingClass().qualifiedName()}#${field.name()} ${field.containingClass().simpleName()}#${field.name()}} ")
- } else {
- reporter.report(
- Errors.MISSING_COLUMN, item,
- "Feature field $value required by $item is hidden or removed"
- )
- sb.append("${field.containingClass().simpleName()}#${field.name()} ")
- }
- }
-
- if (readOnly) {
- sb.append(", and are read-only and cannot be mutated")
- }
- sb.append(".")
- appendDocumentation(sb.toString(), item, false)
- }
})
}
diff --git a/src/main/java/com/android/tools/metalava/doclava1/Errors.java b/src/main/java/com/android/tools/metalava/doclava1/Errors.java
index dfb78b9..8621c5c 100644
--- a/src/main/java/com/android/tools/metalava/doclava1/Errors.java
+++ b/src/main/java/com/android/tools/metalava/doclava1/Errors.java
@@ -258,7 +258,6 @@
// and (2) the principle is adopted by the API council
public static final Error EXTENDS_DEPRECATED = new Error(161, HIDDEN);
public static final Error FORBIDDEN_TAG = new Error(162, ERROR);
- public static final Error MISSING_COLUMN = new Error(163, WARNING, Category.DOCUMENTATION);
// API lint
public static final Error START_WITH_LOWER = new Error(300, ERROR, Category.API_LINT, "S1");
diff --git a/src/test/java/com/android/tools/metalava/DocAnalyzerTest.kt b/src/test/java/com/android/tools/metalava/DocAnalyzerTest.kt
index 5b4efcf..5811331 100644
--- a/src/test/java/com/android/tools/metalava/DocAnalyzerTest.kt
+++ b/src/test/java/com/android/tools/metalava/DocAnalyzerTest.kt
@@ -1869,75 +1869,4 @@
dir.deleteRecursively()
}
-
- @Test
- fun `Test Column annotation`() {
- // Bug: 120429729
- check(
- sourceFiles = *arrayOf(
- java(
- """
- package test.pkg;
- import android.provider.Column;
- import android.database.Cursor;
- @SuppressWarnings("WeakerAccess")
- public class ColumnTest {
- @Column(Cursor.FIELD_TYPE_STRING)
- public static final String DATA = "_data";
- @Column(value = Cursor.FIELD_TYPE_BLOB, readOnly = true)
- public static final String HASH = "_hash";
- @Column(value = Cursor.FIELD_TYPE_STRING, readOnly = true)
- public static final String TITLE = "title";
- @Column(value = Cursor.NONEXISTENT, readOnly = true)
- public static final String BOGUS = "bogus";
- }
- """
- ),
- java(
- """
- package android.database;
- public interface Cursor {
- int FIELD_TYPE_NULL = 0;
- int FIELD_TYPE_INTEGER = 1;
- int FIELD_TYPE_FLOAT = 2;
- int FIELD_TYPE_STRING = 3;
- int FIELD_TYPE_BLOB = 4;
- }
- """
- ),
- columnSource
- ),
- checkCompilation = true,
- checkDoclava1 = false,
- warnings = """
- src/test/pkg/ColumnTest.java:12: warning: Cannot find feature field for Cursor.NONEXISTENT required by field ColumnTest.BOGUS (may be hidden or removed) [MissingColumn]
- """,
- stubs = arrayOf(
- """
- package test.pkg;
- import android.database.Cursor;
- @SuppressWarnings({"unchecked", "deprecation", "all"})
- public class ColumnTest {
- public ColumnTest() { throw new RuntimeException("Stub!"); }
- /**
- * This constant represents a column name that can be used with a {@link android.content.ContentProvider} through a {@link android.content.ContentValues} or {@link android.database.Cursor} object. The values stored in this column are {@link Cursor.NONEXISTENT}, and are read-only and cannot be mutated.
- */
- @android.provider.Column(value=Cursor.NONEXISTENT, readOnly=true) public static final java.lang.String BOGUS = "bogus";
- /**
- * This constant represents a column name that can be used with a {@link android.content.ContentProvider} through a {@link android.content.ContentValues} or {@link android.database.Cursor} object. The values stored in this column are {@link android.database.Cursor#FIELD_TYPE_STRING Cursor#FIELD_TYPE_STRING} .
- */
- @android.provider.Column(android.database.Cursor.FIELD_TYPE_STRING) public static final java.lang.String DATA = "_data";
- /**
- * This constant represents a column name that can be used with a {@link android.content.ContentProvider} through a {@link android.content.ContentValues} or {@link android.database.Cursor} object. The values stored in this column are {@link android.database.Cursor#FIELD_TYPE_BLOB Cursor#FIELD_TYPE_BLOB} , and are read-only and cannot be mutated.
- */
- @android.provider.Column(value=android.database.Cursor.FIELD_TYPE_BLOB, readOnly=true) public static final java.lang.String HASH = "_hash";
- /**
- * This constant represents a column name that can be used with a {@link android.content.ContentProvider} through a {@link android.content.ContentValues} or {@link android.database.Cursor} object. The values stored in this column are {@link android.database.Cursor#FIELD_TYPE_STRING Cursor#FIELD_TYPE_STRING} , and are read-only and cannot be mutated.
- */
- @android.provider.Column(value=android.database.Cursor.FIELD_TYPE_STRING, readOnly=true) public static final java.lang.String TITLE = "title";
- }
- """
- )
- )
- }
}
\ No newline at end of file
diff --git a/src/test/java/com/android/tools/metalava/DriverTest.kt b/src/test/java/com/android/tools/metalava/DriverTest.kt
index 5618e94..8db14dc 100644
--- a/src/test/java/com/android/tools/metalava/DriverTest.kt
+++ b/src/test/java/com/android/tools/metalava/DriverTest.kt
@@ -2453,28 +2453,3 @@
}
"""
).indented()
-
-val columnSource: TestFile = java(
- """
- package android.provider;
-
- import static java.lang.annotation.ElementType.FIELD;
- import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
- import android.content.ContentProvider;
- import android.content.ContentValues;
- import android.database.Cursor;
-
- import java.lang.annotation.Documented;
- import java.lang.annotation.Retention;
- import java.lang.annotation.Target;
-
- @Documented
- @Retention(RUNTIME)
- @Target({FIELD})
- public @interface Column {
- int value();
- boolean readOnly() default false;
- }
- """
-).indented()
\ No newline at end of file