langtools/test/tools/javac/tree/AbstractTreeScannerTest.java
changeset 6601 90c4a1a64217
parent 6597 9367c22c445f
child 7846 f72ce57eb9c1
equal deleted inserted replaced
6600:b3bb16faccc2 6601:90c4a1a64217
   180         System.err.println(msg);
   180         System.err.println(msg);
   181         errors++;
   181         errors++;
   182     }
   182     }
   183 
   183 
   184     /**
   184     /**
       
   185      * Report an error. When the program is complete, the program will either
       
   186      * exit or throw an Error if any errors have been reported.
       
   187      * @param msg the error message
       
   188      */
       
   189     void error(JavaFileObject file, String msg) {
       
   190         System.err.println(file.getName() + ": " + msg);
       
   191         errors++;
       
   192     }
       
   193 
       
   194     /**
   185      *  Report an error for a specific tree node.
   195      *  Report an error for a specific tree node.
   186      *  @param file the source file for the tree
   196      *  @param file the source file for the tree
   187      *  @param t    the tree node
   197      *  @param t    the tree node
   188      *  @param label an indication of the error
   198      *  @param label an indication of the error
   189      */
   199      */
   195     /**
   205     /**
   196      * Get a trimmed string for a tree node, with normalized white space and limited length.
   206      * Get a trimmed string for a tree node, with normalized white space and limited length.
   197      */
   207      */
   198     String trim(Tree tree, int len) {
   208     String trim(Tree tree, int len) {
   199         JCTree t = (JCTree) tree;
   209         JCTree t = (JCTree) tree;
   200         String s = t.toString().replaceAll("[\r\n]+", " ").replaceAll(" +", " ");
   210         String s = t.toString().replaceAll("\\s+", " ");
   201         return (s.length() < len) ? s : s.substring(0, len);
   211         return (s.length() < len) ? s : s.substring(0, len);
   202     }
   212     }
   203 
   213 
   204     /** Number of files that have been analyzed. */
   214     /** Number of files that have been analyzed. */
   205     int fileCount;
   215     int fileCount;