< prev index next >

test/langtools/tools/javac/doctree/DocCommentTester.java

Print this page




 766 
 767             void indent(int n) {
 768                 indent += n;
 769             }
 770 
 771             String compress(String s) {
 772                 s = s.replace("\n", "|").replace(" ", "_");
 773                 return (s.length() < 32)
 774                         ? s
 775                         : s.substring(0, 16) + "..." + s.substring(16);
 776             }
 777 
 778             String quote(String s) {
 779                 if (s.contains("\""))
 780                     return "'" + s + "'";
 781                 else if (s.contains("'") || s.contains(" "))
 782                     return '"' + s + '"';
 783                 else
 784                     return s;
 785             }











 786         }
 787     }
 788 
 789     /**
 790      * Verify the reported tree positions by comparing the characters found
 791      * at and after the reported position with the beginning of the pretty-
 792      * printed text.
 793      */
 794     static class PosChecker extends Checker {
 795         PosChecker(DocCommentTester test, DocTrees t) {
 796             test.super(t);
 797         }
 798 
 799         @Override
 800         void check(TreePath path, Name name) throws Exception {
 801             JavaFileObject fo = path.getCompilationUnit().getSourceFile();
 802             final CharSequence cs = fo.getCharContent(true);
 803 
 804             final DCDocComment dc = (DCDocComment) trees.getDocCommentTree(path);
 805             DCTree t = (DCTree) trees.getDocCommentTree(path);




 766 
 767             void indent(int n) {
 768                 indent += n;
 769             }
 770 
 771             String compress(String s) {
 772                 s = s.replace("\n", "|").replace(" ", "_");
 773                 return (s.length() < 32)
 774                         ? s
 775                         : s.substring(0, 16) + "..." + s.substring(16);
 776             }
 777 
 778             String quote(String s) {
 779                 if (s.contains("\""))
 780                     return "'" + s + "'";
 781                 else if (s.contains("'") || s.contains(" "))
 782                     return '"' + s + '"';
 783                 else
 784                     return s;
 785             }
 786 
 787             @Override
 788             public Void visitAccessor(AccessorTree node, Void p) {
 789                 header(node);
 790                 indent(+1);
 791                 print("description", node.getDescription());
 792                 indent(-1);
 793                 indent();
 794                 out.println("]");
 795                 return null;
 796             }
 797         }
 798     }
 799 
 800     /**
 801      * Verify the reported tree positions by comparing the characters found
 802      * at and after the reported position with the beginning of the pretty-
 803      * printed text.
 804      */
 805     static class PosChecker extends Checker {
 806         PosChecker(DocCommentTester test, DocTrees t) {
 807             test.super(t);
 808         }
 809 
 810         @Override
 811         void check(TreePath path, Name name) throws Exception {
 812             JavaFileObject fo = path.getCompilationUnit().getSourceFile();
 813             final CharSequence cs = fo.getCharContent(true);
 814 
 815             final DCDocComment dc = (DCDocComment) trees.getDocCommentTree(path);
 816             DCTree t = (DCTree) trees.getDocCommentTree(path);


< prev index next >