94 linkInfo.type = type.getComponentType(); |
94 linkInfo.type = type.getComponentType(); |
95 visit(linkInfo.type, linkInfo); |
95 visit(linkInfo.type, linkInfo); |
96 currentDepth--; |
96 currentDepth--; |
97 if (utils.isAnnotated(type)) { |
97 if (utils.isAnnotated(type)) { |
98 linkInfo.type = type; |
98 linkInfo.type = type; |
99 link.addContent(" "); |
99 link.add(" "); |
100 link.addContent(getTypeAnnotationLinks(linkInfo)); |
100 link.add(getTypeAnnotationLinks(linkInfo)); |
101 } |
101 } |
102 // use vararg if required |
102 // use vararg if required |
103 if (linkInfo.isVarArg && currentDepth == 0) { |
103 if (linkInfo.isVarArg && currentDepth == 0) { |
104 link.addContent("..."); |
104 link.add("..."); |
105 } else { |
105 } else { |
106 link.addContent("[]"); |
106 link.add("[]"); |
107 } |
107 } |
108 return link; |
108 return link; |
109 } |
109 } |
110 |
110 |
111 @Override |
111 @Override |
112 public Content visitWildcard(WildcardType type, LinkInfo linkInfo) { |
112 public Content visitWildcard(WildcardType type, LinkInfo linkInfo) { |
113 linkInfo.isTypeBound = true; |
113 linkInfo.isTypeBound = true; |
114 link.addContent("?"); |
114 link.add("?"); |
115 TypeMirror extendsBound = type.getExtendsBound(); |
115 TypeMirror extendsBound = type.getExtendsBound(); |
116 if (extendsBound != null) { |
116 if (extendsBound != null) { |
117 link.addContent(" extends "); |
117 link.add(" extends "); |
118 setBoundsLinkInfo(linkInfo, extendsBound); |
118 setBoundsLinkInfo(linkInfo, extendsBound); |
119 link.addContent(getLink(linkInfo)); |
119 link.add(getLink(linkInfo)); |
120 } |
120 } |
121 TypeMirror superBound = type.getSuperBound(); |
121 TypeMirror superBound = type.getSuperBound(); |
122 if (superBound != null) { |
122 if (superBound != null) { |
123 link.addContent(" super "); |
123 link.add(" super "); |
124 setBoundsLinkInfo(linkInfo, superBound); |
124 setBoundsLinkInfo(linkInfo, superBound); |
125 link.addContent(getLink(linkInfo)); |
125 link.add(getLink(linkInfo)); |
126 } |
126 } |
127 return link; |
127 return link; |
128 } |
128 } |
129 |
129 |
130 @Override |
130 @Override |
131 public Content visitTypeVariable(TypeVariable type, LinkInfo linkInfo) { |
131 public Content visitTypeVariable(TypeVariable type, LinkInfo linkInfo) { |
132 link.addContent(getTypeAnnotationLinks(linkInfo)); |
132 link.add(getTypeAnnotationLinks(linkInfo)); |
133 linkInfo.isTypeBound = true; |
133 linkInfo.isTypeBound = true; |
134 TypeVariable typevariable = (utils.isArrayType(type)) |
134 TypeVariable typevariable = (utils.isArrayType(type)) |
135 ? (TypeVariable) componentType |
135 ? (TypeVariable) componentType |
136 : type; |
136 : type; |
137 Element owner = typevariable.asElement().getEnclosingElement(); |
137 Element owner = typevariable.asElement().getEnclosingElement(); |
138 if ((!linkInfo.excludeTypeParameterLinks) && utils.isTypeElement(owner)) { |
138 if ((!linkInfo.excludeTypeParameterLinks) && utils.isTypeElement(owner)) { |
139 linkInfo.typeElement = (TypeElement) owner; |
139 linkInfo.typeElement = (TypeElement) owner; |
140 Content label = newContent(); |
140 Content label = newContent(); |
141 label.addContent(utils.getTypeName(type, false)); |
141 label.add(utils.getTypeName(type, false)); |
142 linkInfo.label = label; |
142 linkInfo.label = label; |
143 link.addContent(getClassLink(linkInfo)); |
143 link.add(getClassLink(linkInfo)); |
144 } else { |
144 } else { |
145 // No need to link method type parameters. |
145 // No need to link method type parameters. |
146 link.addContent(utils.getTypeName(typevariable, false)); |
146 link.add(utils.getTypeName(typevariable, false)); |
147 } |
147 } |
148 |
148 |
149 if (!linkInfo.excludeTypeBounds) { |
149 if (!linkInfo.excludeTypeBounds) { |
150 linkInfo.excludeTypeBounds = true; |
150 linkInfo.excludeTypeBounds = true; |
151 TypeParameterElement tpe = ((TypeParameterElement) typevariable.asElement()); |
151 TypeParameterElement tpe = ((TypeParameterElement) typevariable.asElement()); |
171 @Override |
171 @Override |
172 public Content visitDeclared(DeclaredType type, LinkInfo linkInfo) { |
172 public Content visitDeclared(DeclaredType type, LinkInfo linkInfo) { |
173 if (linkInfo.isTypeBound && linkInfo.excludeTypeBoundsLinks) { |
173 if (linkInfo.isTypeBound && linkInfo.excludeTypeBoundsLinks) { |
174 // Since we are excluding type parameter links, we should not |
174 // Since we are excluding type parameter links, we should not |
175 // be linking to the type bound. |
175 // be linking to the type bound. |
176 link.addContent(utils.getTypeName(type, false)); |
176 link.add(utils.getTypeName(type, false)); |
177 link.addContent(getTypeParameterLinks(linkInfo)); |
177 link.add(getTypeParameterLinks(linkInfo)); |
178 return link; |
178 return link; |
179 } else { |
179 } else { |
180 link = newContent(); |
180 link = newContent(); |
181 link.addContent(getTypeAnnotationLinks(linkInfo)); |
181 link.add(getTypeAnnotationLinks(linkInfo)); |
182 linkInfo.typeElement = utils.asTypeElement(type); |
182 linkInfo.typeElement = utils.asTypeElement(type); |
183 link.addContent(getClassLink(linkInfo)); |
183 link.add(getClassLink(linkInfo)); |
184 if (linkInfo.includeTypeAsSepLink) { |
184 if (linkInfo.includeTypeAsSepLink) { |
185 link.addContent(getTypeParameterLinks(linkInfo, false)); |
185 link.add(getTypeParameterLinks(linkInfo, false)); |
186 } |
186 } |
187 } |
187 } |
188 return link; |
188 return link; |
189 } |
189 } |
190 }; |
190 }; |
191 return linkVisitor.visit(linkInfo.type, linkInfo); |
191 return linkVisitor.visit(linkInfo.type, linkInfo); |
192 } else if (linkInfo.typeElement != null) { |
192 } else if (linkInfo.typeElement != null) { |
193 Content link = newContent(); |
193 Content link = newContent(); |
194 link.addContent(getClassLink(linkInfo)); |
194 link.add(getClassLink(linkInfo)); |
195 if (linkInfo.includeTypeAsSepLink) { |
195 if (linkInfo.includeTypeAsSepLink) { |
196 link.addContent(getTypeParameterLinks(linkInfo, false)); |
196 link.add(getTypeParameterLinks(linkInfo, false)); |
197 } |
197 } |
198 return link; |
198 return link; |
199 } else { |
199 } else { |
200 return null; |
200 return null; |
201 } |
201 } |