summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-06-13 07:11:15 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-06-13 07:11:15 +0000
commit78f2890124d925dc0bc065f9394f1031cfad5edd (patch)
tree6f4004eff7d527ca4033103148a453c5b502a831
parent440fb9b69576c3ebc07de1d3b7e58c7a283ed632 (diff)
parent759ebc50f3a329bcad19dd0a74d90b80bfd71204 (diff)
downloadplatform_external_doclava-oreo-r3-release.tar.gz
platform_external_doclava-oreo-r3-release.tar.bz2
platform_external_doclava-oreo-r3-release.zip
Change-Id: Iba38d0b22b81234c054c86e5ce138e7252c5bb41
-rw-r--r--src/com/google/doclava/AndroidAuxSource.java34
-rw-r--r--src/com/google/doclava/AuxSource.java4
-rw-r--r--src/com/google/doclava/MethodInfo.java2
3 files changed, 31 insertions, 9 deletions
diff --git a/src/com/google/doclava/AndroidAuxSource.java b/src/com/google/doclava/AndroidAuxSource.java
index d006af0..8ed9fb0 100644
--- a/src/com/google/doclava/AndroidAuxSource.java
+++ b/src/com/google/doclava/AndroidAuxSource.java
@@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.regex.Pattern;
public class AndroidAuxSource implements AuxSource {
private static final int TYPE_FIELD = 0;
@@ -77,31 +78,44 @@ public class AndroidAuxSource implements AuxSource {
@Override
public TagInfo[] fieldAuxTags(FieldInfo field) {
if (hasSuppress(field)) return TagInfo.EMPTY_ARRAY;
- return auxTags(TYPE_FIELD, field.annotations());
+ return auxTags(TYPE_FIELD, field.annotations(), toString(field.inlineTags()));
}
@Override
public TagInfo[] methodAuxTags(MethodInfo method) {
if (hasSuppress(method)) return TagInfo.EMPTY_ARRAY;
- return auxTags(TYPE_METHOD, method.annotations());
+ return auxTags(TYPE_METHOD, method.annotations(), toString(method.inlineTags().tags()));
}
@Override
- public TagInfo[] paramAuxTags(MethodInfo method, ParameterInfo param) {
+ public TagInfo[] paramAuxTags(MethodInfo method, ParameterInfo param, String comment) {
if (hasSuppress(method)) return TagInfo.EMPTY_ARRAY;
if (hasSuppress(param.annotations())) return TagInfo.EMPTY_ARRAY;
- return auxTags(TYPE_PARAM, param.annotations());
+ return auxTags(TYPE_PARAM, param.annotations(), new String[] { comment });
}
@Override
public TagInfo[] returnAuxTags(MethodInfo method) {
if (hasSuppress(method)) return TagInfo.EMPTY_ARRAY;
- return auxTags(TYPE_RETURN, method.annotations());
+ return auxTags(TYPE_RETURN, method.annotations(), toString(method.returnTags().tags()));
}
- private static TagInfo[] auxTags(int type, List<AnnotationInstanceInfo> annotations) {
+ private static TagInfo[] auxTags(int type, List<AnnotationInstanceInfo> annotations,
+ String[] comment) {
ArrayList<TagInfo> tags = new ArrayList<>();
for (AnnotationInstanceInfo annotation : annotations) {
+ // Ignore null-related annotations when docs already mention
+ if (annotation.type().qualifiedNameMatches("android", "annotation.NonNull")
+ || annotation.type().qualifiedNameMatches("android", "annotation.Nullable")) {
+ boolean mentionsNull = false;
+ for (String c : comment) {
+ mentionsNull |= Pattern.compile("\\bnull\\b").matcher(c).find();
+ }
+ if (mentionsNull) {
+ continue;
+ }
+ }
+
// Blindly include docs requested by annotations
ParsedTagInfo[] docTags = ParsedTagInfo.EMPTY_ARRAY;
switch (type) {
@@ -238,6 +252,14 @@ public class AndroidAuxSource implements AuxSource {
return tags.toArray(TagInfo.getArray(tags.size()));
}
+ private static String[] toString(TagInfo[] tags) {
+ final String[] res = new String[tags.length];
+ for (int i = 0; i < res.length; i++) {
+ res[i] = tags[i].text();
+ }
+ return res;
+ }
+
private static boolean hasSuppress(MemberInfo member) {
return hasSuppress(member.annotations())
|| hasSuppress(member.containingClass().annotations());
diff --git a/src/com/google/doclava/AuxSource.java b/src/com/google/doclava/AuxSource.java
index 03594f5..df03546 100644
--- a/src/com/google/doclava/AuxSource.java
+++ b/src/com/google/doclava/AuxSource.java
@@ -20,7 +20,7 @@ public interface AuxSource {
public TagInfo[] classAuxTags(ClassInfo clazz);
public TagInfo[] fieldAuxTags(FieldInfo field);
public TagInfo[] methodAuxTags(MethodInfo method);
- public TagInfo[] paramAuxTags(MethodInfo method, ParameterInfo param);
+ public TagInfo[] paramAuxTags(MethodInfo method, ParameterInfo param, String comment);
public TagInfo[] returnAuxTags(MethodInfo method);
}
@@ -41,7 +41,7 @@ class EmptyAuxSource implements AuxSource {
}
@Override
- public TagInfo[] paramAuxTags(MethodInfo method, ParameterInfo param) {
+ public TagInfo[] paramAuxTags(MethodInfo method, ParameterInfo param, String comment) {
return TagInfo.EMPTY_ARRAY;
}
diff --git a/src/com/google/doclava/MethodInfo.java b/src/com/google/doclava/MethodInfo.java
index 5ed58eb..47b1978 100644
--- a/src/com/google/doclava/MethodInfo.java
+++ b/src/com/google/doclava/MethodInfo.java
@@ -513,7 +513,7 @@ public class MethodInfo extends MemberInfo implements AbstractMethodInfo, Resolv
}
// Collect all docs requested by annotations
- TagInfo[] auxTags = Doclava.auxSource.paramAuxTags(this, param);
+ TagInfo[] auxTags = Doclava.auxSource.paramAuxTags(this, param, comment);
// Okay, now add the collected parameter information to the method data
mParamTags[i] =