Don't add bounds in the type info of a var.
Showing bounds in the type info leads to generated stubs that don't
build.
The problem occurs when you have a generic class
class MyClass<V extends SomeClass> {
List<? super V> items;
}
doclava currently generates:
class MyClass<V extends SomeClass> {
List<? super V extends SomeClass> items;
}
Which doesn't build. With this change, it doesn't put "V extends
SomeClass" in the type info for items, but just "V" instead.
Change-Id: Iaa9b1bdeec96951868ba77a4eb55c566f19179ca
diff --git a/src/com/google/doclava/TypeInfo.java b/src/com/google/doclava/TypeInfo.java
index 048d0ea..36d9634 100644
--- a/src/com/google/doclava/TypeInfo.java
+++ b/src/com/google/doclava/TypeInfo.java
@@ -150,38 +150,61 @@
return mFullName;
}
- public String fullNameNoDimension(HashSet<String> typeVars) {
- String fullName = null;
+ public String fullNameNoBounds(HashSet<String> typeVars) {
+ return fullNameNoDimensionNoBounds(typeVars) + mDimension;
+ }
+
+ // don't recurse forever with the parameters. This handles
+ // Enum<K extends Enum<K>>
+ private boolean checkRecurringTypeVar(HashSet<String> typeVars) {
if (mIsTypeVariable) {
if (typeVars.contains(mQualifiedTypeName)) {
- // don't recurse forever with the parameters. This handles
- // Enum<K extends Enum<K>>
- return mQualifiedTypeName;
+ return true;
}
typeVars.add(mQualifiedTypeName);
}
+ return false;
+ }
+
+ private String fullNameNoDimensionNoBounds(HashSet<String> typeVars) {
+ String fullName = null;
+ if (checkRecurringTypeVar(typeVars)) {
+ return mQualifiedTypeName;
+ }
/*
* if (fullName != null) { return fullName; }
*/
fullName = mQualifiedTypeName;
if (mTypeArguments != null && !mTypeArguments.isEmpty()) {
fullName += typeArgumentsName(mTypeArguments, typeVars);
- } else if (mSuperBounds != null && !mSuperBounds.isEmpty()) {
+ }
+ return fullName;
+ }
+
+ public String fullNameNoDimension(HashSet<String> typeVars) {
+ String fullName = null;
+ if (checkRecurringTypeVar(typeVars)) {
+ return mQualifiedTypeName;
+ }
+ fullName = fullNameNoDimensionNoBounds(typeVars);
+ if (mTypeArguments == null || mTypeArguments.isEmpty()) {
+ if (mSuperBounds != null && !mSuperBounds.isEmpty()) {
for (TypeInfo superBound : mSuperBounds) {
if (superBound == mSuperBounds.get(0)) {
- fullName += " super " + superBound.fullName(typeVars);
+ fullName += " super " + superBound.fullNameNoBounds(typeVars);
} else {
- fullName += " & " + superBound.fullName(typeVars);
+ fullName += " & " + superBound.fullNameNoBounds(typeVars);
}
}
- } else if (mExtendsBounds != null && !mExtendsBounds.isEmpty()) {
+ } else if (mExtendsBounds != null && !mExtendsBounds.isEmpty()) {
for (TypeInfo extendsBound : mExtendsBounds) {
if (extendsBound == mExtendsBounds.get(0)) {
- fullName += " extends " + extendsBound.fullName(typeVars);
+ fullName += " extends " + extendsBound.fullNameNoBounds(typeVars);
} else {
- fullName += " & " + extendsBound.fullName(typeVars);
+ fullName += " & " + extendsBound.fullNameNoBounds(typeVars);
}
}
+ }
}
return fullName;
}