summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2019-02-15 13:16:35 -0700
committerJeff Sharkey <jsharkey@android.com>2019-02-15 13:47:51 -0700
commit176e9f57be142ec55556e0f4ab781df6e393c0ee (patch)
tree839de8622f1089905b4a33128751f7e821fcf4ce /src
parent759e89fc1067031c3c3c8c4d74e1144a2a2ee5b3 (diff)
downloaddoclava-176e9f57be142ec55556e0f4ab781df6e393c0ee.tar.gz
Automatic documentation for "@Column" annotation.
We have various "contract" classes across the OS which describe the columns that are available for insert(), update(), and query() when working with ContentProviders. To help ensure that the underlying providers fully support the API contracts being made, this change defines a new "@Column" annotation which describes the underlying data type. These annotations can then be used by the ContentProvider implementations internally to ensure that they're fully meeting the API contracts being made. Bug: 120429729 Test: manual Change-Id: Iffeb5fce4a1186e0b4aa3424ecb69a34f6607c21
Diffstat (limited to 'src')
-rw-r--r--src/com/google/doclava/AndroidAuxSource.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/com/google/doclava/AndroidAuxSource.java b/src/com/google/doclava/AndroidAuxSource.java
index 1c97b18..ca1fbd0 100644
--- a/src/com/google/doclava/AndroidAuxSource.java
+++ b/src/com/google/doclava/AndroidAuxSource.java
@@ -219,6 +219,46 @@ public class AndroidAuxSource implements AuxSource {
valueTags.toArray(TagInfo.getArray(valueTags.size()))));
}
+ // Document provider columns
+ if ((type == TYPE_FIELD) && annotation.type().qualifiedNameMatches("android", "Column")) {
+ String value = null;
+ boolean readOnly = false;
+ for (AnnotationValueInfo val : annotation.elementValues()) {
+ switch (val.element().name()) {
+ case "value":
+ value = String.valueOf(val.value());
+ break;
+ case "readOnly":
+ readOnly = Boolean.parseBoolean(String.valueOf(val.value()));
+ break;
+ }
+ }
+
+ ArrayList<TagInfo> valueTags = new ArrayList<>();
+ valueTags.add(new ParsedTagInfo("", "",
+ "{@link android.content.ContentProvider}", null, SourcePositionInfo.UNKNOWN));
+ valueTags.add(new ParsedTagInfo("", "",
+ "{@link android.content.ContentValues}", null, SourcePositionInfo.UNKNOWN));
+ valueTags.add(new ParsedTagInfo("", "",
+ "{@link android.database.Cursor}", null, SourcePositionInfo.UNKNOWN));
+
+ ClassInfo cursorClass = annotation.type().findClass("android.database.Cursor");
+ for (FieldInfo field : cursorClass.fields()) {
+ if (field.isHiddenOrRemoved()) continue;
+ if (String.valueOf(field.constantValue()).equals(value)) {
+ valueTags.add(new ParsedTagInfo("", "",
+ "{@link android.database.Cursor#" + field.name() + "}",
+ null, SourcePositionInfo.UNKNOWN));
+ }
+ }
+ if (valueTags.size() < 4) continue;
+
+ Map<String, String> args = new HashMap<>();
+ if (readOnly) args.put("readOnly", "true");
+ tags.add(new AuxTagInfo("@column", "@column", SourcePositionInfo.UNKNOWN, args,
+ valueTags.toArray(TagInfo.getArray(valueTags.size()))));
+ }
+
// The remaining annotations below always appear on return docs, and
// should not be included in the method body
if (type == TYPE_METHOD) continue;