diff options
author | Omari Stephens <xsdg@android.com> | 2015-06-04 21:29:09 -0700 |
---|---|---|
committer | Clay Murphy <claym@google.com> | 2015-08-10 17:51:26 -0700 |
commit | 274a19e4c4a6dc90d1a71b5f5c54438f343868a5 (patch) | |
tree | 7aea85a92dc5fd0cfe22a519d5c675d4ea1f6078 /src/com/google | |
parent | d8bb1ec9efccbbcc48d8d4991c9d4001fa31eeb5 (diff) | |
download | android_external_doclava-274a19e4c4a6dc90d1a71b5f5c54438f343868a5.tar.gz android_external_doclava-274a19e4c4a6dc90d1a71b5f5c54438f343868a5.tar.bz2 android_external_doclava-274a19e4c4a6dc90d1a71b5f5c54438f343868a5.zip |
Display annotations and annotation values when they are requested
(cherry-picked from commit 6fa3e41df1664e59c13830b012b9be39c2b31cae)
This exports the annotation field names and values, as well as displays them
in the generated output whenever the annotation is chosen with the
"-showAnnotation" argument to doclava
Bug: 8440225
Change-Id: Iea71d3af2593e5067f4b1b1fbd3463539609f676
Diffstat (limited to 'src/com/google')
-rw-r--r-- | src/com/google/doclava/AnnotationInstanceInfo.java | 16 | ||||
-rw-r--r-- | src/com/google/doclava/MemberInfo.java | 15 |
2 files changed, 28 insertions, 3 deletions
diff --git a/src/com/google/doclava/AnnotationInstanceInfo.java b/src/com/google/doclava/AnnotationInstanceInfo.java index c72ca9a..d353426 100644 --- a/src/com/google/doclava/AnnotationInstanceInfo.java +++ b/src/com/google/doclava/AnnotationInstanceInfo.java @@ -120,13 +120,27 @@ public class AnnotationInstanceInfo implements Resolvable { return allResolved; } + /** + * Convert the specified list of {@code AnnotationInstanceInfo} into an HDF-formatted list, and + * add the HDF list into the specified {@code Data}. + */ public static void makeLinkListHDF(Data data, String base, AnnotationInstanceInfo[] annotations) { if (annotations == null) return; final int N = annotations.length; for (int i = 0; i < N; i++) { AnnotationInstanceInfo aii = annotations[i]; - aii.type().makeShortDescrHDF(data, base + "." + i); + final String aiiBase = base + "." + i; + + // Serialize data about the annotation element values + for (int elemIdx = 0; elemIdx < aii.elementValues().size(); ++elemIdx) { + final String elemBase = aiiBase + ".elementValues." + elemIdx; + final AnnotationValueInfo value = aii.elementValues().get(elemIdx); + data.setValue(elemBase + ".name", value.element().name()); + data.setValue(elemBase + ".value", value.valueString()); + } + + aii.type().makeShortDescrHDF(data, aiiBase); } } diff --git a/src/com/google/doclava/MemberInfo.java b/src/com/google/doclava/MemberInfo.java index 76087eb..da11360 100644 --- a/src/com/google/doclava/MemberInfo.java +++ b/src/com/google/doclava/MemberInfo.java @@ -143,9 +143,20 @@ public abstract class MemberInfo extends DocInfo implements Comparable, Scoped { return mContainingClass; } + /** + * Returns {@code true} if the member's scope is above the minimum requested scope passed to + * Doclava, <emph>or</emph> if the member is tagged with an annotation which was specified in a + * "-showAnnotation" argument to Doclava + */ public boolean checkLevel() { - return Doclava.checkLevel(mIsPublic, mIsProtected, mIsPackagePrivate, mIsPrivate, - isHiddenOrRemoved()); + if (Doclava.checkLevel(mIsPublic, mIsProtected, mIsPackagePrivate, mIsPrivate, + isHiddenOrRemoved())) { + return true; + } else if (mShowAnnotations != null && !mShowAnnotations.isEmpty()) { + return true; + } + + return false; } public String kind() { |