equal
deleted
inserted
replaced
365 * toplevel tree. |
365 * toplevel tree. |
366 */ |
366 */ |
367 public void printUnit(JCCompilationUnit tree, JCClassDecl cdef) throws IOException { |
367 public void printUnit(JCCompilationUnit tree, JCClassDecl cdef) throws IOException { |
368 docComments = tree.docComments; |
368 docComments = tree.docComments; |
369 printDocComment(tree); |
369 printDocComment(tree); |
370 if (tree.pid != null) { |
370 |
371 print("package "); |
|
372 printExpr(tree.pid); |
|
373 print(";"); |
|
374 println(); |
|
375 } |
|
376 boolean firstImport = true; |
371 boolean firstImport = true; |
377 for (List<JCTree> l = tree.defs; |
372 for (List<JCTree> l = tree.defs; |
378 l.nonEmpty() && (cdef == null || l.head.hasTag(IMPORT)); |
373 l.nonEmpty() && |
379 l = l.tail) { |
374 (cdef == null || |
|
375 l.head.hasTag(IMPORT) || l.head.hasTag(PACKAGEDEF)); |
|
376 l = l.tail) { |
380 if (l.head.hasTag(IMPORT)) { |
377 if (l.head.hasTag(IMPORT)) { |
381 JCImport imp = (JCImport)l.head; |
378 JCImport imp = (JCImport)l.head; |
382 Name name = TreeInfo.name(imp.qualid); |
379 Name name = TreeInfo.name(imp.qualid); |
383 if (name == name.table.names.asterisk || |
380 if (name == name.table.names.asterisk || |
384 cdef == null || |
381 cdef == null || |
419 *************************************************************************/ |
416 *************************************************************************/ |
420 |
417 |
421 public void visitTopLevel(JCCompilationUnit tree) { |
418 public void visitTopLevel(JCCompilationUnit tree) { |
422 try { |
419 try { |
423 printUnit(tree, null); |
420 printUnit(tree, null); |
|
421 } catch (IOException e) { |
|
422 throw new UncheckedIOException(e); |
|
423 } |
|
424 } |
|
425 |
|
426 public void visitPackageDef(JCPackageDecl tree) { |
|
427 try { |
|
428 printDocComment(tree); |
|
429 printAnnotations(tree.annotations); |
|
430 if (tree.pid != null) { |
|
431 print("package "); |
|
432 printExpr(tree.pid); |
|
433 print(";"); |
|
434 println(); |
|
435 } |
424 } catch (IOException e) { |
436 } catch (IOException e) { |
425 throw new UncheckedIOException(e); |
437 throw new UncheckedIOException(e); |
426 } |
438 } |
427 } |
439 } |
428 |
440 |