25 |
25 |
26 package com.sun.tools.javac.code; |
26 package com.sun.tools.javac.code; |
27 |
27 |
28 import java.util.Locale; |
28 import java.util.Locale; |
29 |
29 |
30 import javax.lang.model.type.TypeKind; |
|
31 |
|
32 import com.sun.tools.javac.api.Messages; |
30 import com.sun.tools.javac.api.Messages; |
33 import com.sun.tools.javac.code.Type.AnnotatedType; |
31 import com.sun.tools.javac.code.Type.AnnotatedType; |
34 import com.sun.tools.javac.code.Type.ArrayType; |
32 import com.sun.tools.javac.code.Type.ArrayType; |
35 import com.sun.tools.javac.code.Symbol.*; |
33 import com.sun.tools.javac.code.Symbol.*; |
36 import com.sun.tools.javac.code.Type.*; |
34 import com.sun.tools.javac.code.Type.*; |
189 return res.toString(); |
187 return res.toString(); |
190 } |
188 } |
191 |
189 |
192 void printBaseElementType(Type t, StringBuilder sb, Locale locale) { |
190 void printBaseElementType(Type t, StringBuilder sb, Locale locale) { |
193 Type arrel = t; |
191 Type arrel = t; |
194 while (arrel.getKind() == TypeKind.ARRAY) { |
192 while (arrel.hasTag(TypeTag.ARRAY)) { |
195 arrel = arrel.unannotatedType(); |
193 arrel = arrel.unannotatedType(); |
196 arrel = ((ArrayType) arrel).elemtype; |
194 arrel = ((ArrayType) arrel).elemtype; |
197 } |
195 } |
198 sb.append(visit(arrel, locale)); |
196 sb.append(visit(arrel, locale)); |
199 } |
197 } |
200 |
198 |
201 void printBrackets(Type t, StringBuilder sb, Locale locale) { |
199 void printBrackets(Type t, StringBuilder sb, Locale locale) { |
202 Type arrel = t; |
200 Type arrel = t; |
203 while (arrel.getKind() == TypeKind.ARRAY) { |
201 while (arrel.hasTag(TypeTag.ARRAY)) { |
204 if (arrel.isAnnotated()) { |
202 if (arrel.isAnnotated()) { |
205 sb.append(' '); |
203 sb.append(' '); |
206 sb.append(arrel.getAnnotationMirrors()); |
204 sb.append(arrel.getAnnotationMirrors()); |
207 sb.append(' '); |
205 sb.append(' '); |
208 } |
206 } |
262 |
260 |
263 @Override |
261 @Override |
264 public String visitAnnotatedType(AnnotatedType t, Locale locale) { |
262 public String visitAnnotatedType(AnnotatedType t, Locale locale) { |
265 if (t.typeAnnotations != null && |
263 if (t.typeAnnotations != null && |
266 t.typeAnnotations.nonEmpty()) { |
264 t.typeAnnotations.nonEmpty()) { |
267 if (t.underlyingType.getKind() == TypeKind.ARRAY) { |
265 if (t.underlyingType.hasTag(TypeTag.ARRAY)) { |
268 StringBuilder res = new StringBuilder(); |
266 StringBuilder res = new StringBuilder(); |
269 printBaseElementType(t, res, locale); |
267 printBaseElementType(t, res, locale); |
270 printBrackets(t, res, locale); |
268 printBrackets(t, res, locale); |
271 return res.toString(); |
269 return res.toString(); |
272 } else if (t.underlyingType.getKind() == TypeKind.DECLARED && |
270 } else if (t.underlyingType.hasTag(TypeTag.CLASS) && |
273 t.underlyingType.getEnclosingType() != Type.noType) { |
271 t.underlyingType.getEnclosingType() != Type.noType) { |
274 return visit(t.underlyingType.getEnclosingType(), locale) + |
272 return visit(t.underlyingType.getEnclosingType(), locale) + |
275 ". " + |
273 ". " + |
276 t.typeAnnotations + |
274 t.typeAnnotations + |
277 " " + className((ClassType)t.underlyingType, false, locale); |
275 " " + className((ClassType)t.underlyingType, false, locale); |
346 while (args.tail.nonEmpty()) { |
344 while (args.tail.nonEmpty()) { |
347 buf.append(visit(args.head, locale)); |
345 buf.append(visit(args.head, locale)); |
348 args = args.tail; |
346 args = args.tail; |
349 buf.append(','); |
347 buf.append(','); |
350 } |
348 } |
351 if (args.head.unannotatedType().getKind() == TypeKind.ARRAY) { |
349 if (args.head.unannotatedType().hasTag(TypeTag.ARRAY)) { |
352 buf.append(visit(((ArrayType) args.head.unannotatedType()).elemtype, locale)); |
350 buf.append(visit(((ArrayType) args.head.unannotatedType()).elemtype, locale)); |
353 if (args.head.getAnnotationMirrors().nonEmpty()) { |
351 if (args.head.getAnnotationMirrors().nonEmpty()) { |
354 buf.append(' '); |
352 buf.append(' '); |
355 buf.append(args.head.getAnnotationMirrors()); |
353 buf.append(args.head.getAnnotationMirrors()); |
356 buf.append(' '); |
354 buf.append(' '); |