src/share/classes/com/sun/tools/javac/tree/Pretty.java

changeset 1755
ddb4a2bfcd82
parent 1521
71f35e4b93a5
child 1928
05370ef9dccb
equal deleted inserted replaced
1754:0384683c64be 1755:ddb4a2bfcd82
259 align(); 259 align();
260 } 260 }
261 } 261 }
262 262
263 public void printTypeAnnotations(List<JCAnnotation> trees) throws IOException { 263 public void printTypeAnnotations(List<JCAnnotation> trees) throws IOException {
264 if (trees.nonEmpty())
265 print(" ");
266 for (List<JCAnnotation> l = trees; l.nonEmpty(); l = l.tail) { 264 for (List<JCAnnotation> l = trees; l.nonEmpty(); l = l.tail) {
267 printExpr(l.head); 265 printExpr(l.head);
268 print(" "); 266 print(" ");
269 } 267 }
270 } 268 }
562 if (vartype instanceof JCAnnotatedType) { 560 if (vartype instanceof JCAnnotatedType) {
563 tas = ((JCAnnotatedType)vartype).annotations; 561 tas = ((JCAnnotatedType)vartype).annotations;
564 vartype = ((JCAnnotatedType)vartype).underlyingType; 562 vartype = ((JCAnnotatedType)vartype).underlyingType;
565 } 563 }
566 printExpr(((JCArrayTypeTree) vartype).elemtype); 564 printExpr(((JCArrayTypeTree) vartype).elemtype);
567 if (tas != null) 565 if (tas != null) {
566 print(' ');
568 printTypeAnnotations(tas); 567 printTypeAnnotations(tas);
568 }
569 print("... " + tree.name); 569 print("... " + tree.name);
570 } else { 570 } else {
571 printExpr(tree.vartype); 571 printExpr(tree.vartype);
572 print(" " + tree.name); 572 print(" " + tree.name);
573 } 573 }
915 print("new "); 915 print("new ");
916 if (!tree.typeargs.isEmpty()) { 916 if (!tree.typeargs.isEmpty()) {
917 print("<"); 917 print("<");
918 printExprs(tree.typeargs); 918 printExprs(tree.typeargs);
919 print(">"); 919 print(">");
920 }
921 if (tree.def != null && tree.def.mods.annotations.nonEmpty()) {
922 printTypeAnnotations(tree.def.mods.annotations);
920 } 923 }
921 printExpr(tree.clazz); 924 printExpr(tree.clazz);
922 print("("); 925 print("(");
923 printExprs(tree.args); 926 printExprs(tree.args);
924 print(")"); 927 print(")");
946 printBaseElementType(elem); 949 printBaseElementType(elem);
947 boolean isElemAnnoType = elem instanceof JCAnnotatedType; 950 boolean isElemAnnoType = elem instanceof JCAnnotatedType;
948 int i = 0; 951 int i = 0;
949 List<List<JCAnnotation>> da = tree.dimAnnotations; 952 List<List<JCAnnotation>> da = tree.dimAnnotations;
950 for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) { 953 for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) {
951 if (da.size() > i) { 954 if (da.size() > i && !da.get(i).isEmpty()) {
955 print(' ');
952 printTypeAnnotations(da.get(i)); 956 printTypeAnnotations(da.get(i));
953 } 957 }
954 print("["); 958 print("[");
955 i++; 959 i++;
956 printExpr(l.head); 960 printExpr(l.head);
957 print("]"); 961 print("]");
958 } 962 }
959 if (tree.elems != null) { 963 if (tree.elems != null) {
960 if (isElemAnnoType) { 964 if (isElemAnnoType) {
965 print(' ');
961 printTypeAnnotations(((JCAnnotatedType)tree.elemtype).annotations); 966 printTypeAnnotations(((JCAnnotatedType)tree.elemtype).annotations);
962 } 967 }
963 print("[]"); 968 print("[]");
964 } 969 }
965 if (isElemAnnoType) 970 if (isElemAnnoType)
1262 elem = tree.elemtype; 1267 elem = tree.elemtype;
1263 if (elem.hasTag(ANNOTATED_TYPE)) { 1268 if (elem.hasTag(ANNOTATED_TYPE)) {
1264 JCAnnotatedType atype = (JCAnnotatedType) elem; 1269 JCAnnotatedType atype = (JCAnnotatedType) elem;
1265 elem = atype.underlyingType; 1270 elem = atype.underlyingType;
1266 if (!elem.hasTag(TYPEARRAY)) break; 1271 if (!elem.hasTag(TYPEARRAY)) break;
1272 print(' ');
1267 printTypeAnnotations(atype.annotations); 1273 printTypeAnnotations(atype.annotations);
1268 } 1274 }
1269 print("[]"); 1275 print("[]");
1270 if (!elem.hasTag(TYPEARRAY)) break; 1276 if (!elem.hasTag(TYPEARRAY)) break;
1271 tree = (JCArrayTypeTree) elem; 1277 tree = (JCArrayTypeTree) elem;
1299 } 1305 }
1300 } 1306 }
1301 1307
1302 public void visitTypeParameter(JCTypeParameter tree) { 1308 public void visitTypeParameter(JCTypeParameter tree) {
1303 try { 1309 try {
1310 if (tree.annotations.nonEmpty()) {
1311 this.printTypeAnnotations(tree.annotations);
1312 }
1304 print(tree.name); 1313 print(tree.name);
1305 if (tree.bounds.nonEmpty()) { 1314 if (tree.bounds.nonEmpty()) {
1306 print(" extends "); 1315 print(" extends ");
1307 printExprs(tree.bounds, " & "); 1316 printExprs(tree.bounds, " & ");
1308 } 1317 }
1377 printTypeAnnotations(tree.annotations); 1386 printTypeAnnotations(tree.annotations);
1378 print(access.name); 1387 print(access.name);
1379 } else if (tree.underlyingType.getKind() == JCTree.Kind.ARRAY_TYPE) { 1388 } else if (tree.underlyingType.getKind() == JCTree.Kind.ARRAY_TYPE) {
1380 JCArrayTypeTree array = (JCArrayTypeTree) tree.underlyingType; 1389 JCArrayTypeTree array = (JCArrayTypeTree) tree.underlyingType;
1381 printBaseElementType(tree); 1390 printBaseElementType(tree);
1391 print(' ');
1382 printTypeAnnotations(tree.annotations); 1392 printTypeAnnotations(tree.annotations);
1383 print("[]"); 1393 print("[]");
1384 JCExpression elem = array.elemtype; 1394 JCExpression elem = array.elemtype;
1385 if (elem.hasTag(TYPEARRAY)) { 1395 if (elem.hasTag(TYPEARRAY)) {
1386 printBrackets((JCArrayTypeTree) elem); 1396 printBrackets((JCArrayTypeTree) elem);

mercurial