langtools/test/tools/javac/tree/AbstractTreeScannerTest.java
changeset 7846 f72ce57eb9c1
parent 6601 90c4a1a64217
child 10950 e87b50888909
equal deleted inserted replaced
7845:85446adf08d8 7846:f72ce57eb9c1
   141             error("File " + file + " ignored");
   141             error("File " + file + " ignored");
   142     }
   142     }
   143 
   143 
   144     abstract int test(JCCompilationUnit t);
   144     abstract int test(JCCompilationUnit t);
   145 
   145 
       
   146     // See CR:  6982992 Tests CheckAttributedTree.java, JavacTreeScannerTest.java, and SourceTreeeScannerTest.java timeout
       
   147     StringWriter sw = new StringWriter();
       
   148     PrintWriter pw = new PrintWriter(sw);
       
   149     Reporter r = new Reporter(pw);
       
   150     JavacTool tool = JavacTool.create();
       
   151     StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null);
       
   152 
   146     /**
   153     /**
   147      * Read a file.
   154      * Read a file.
   148      * @param file the file to be read
   155      * @param file the file to be read
   149      * @return the tree for the content of the file
   156      * @return the tree for the content of the file
   150      * @throws IOException if any IO errors occur
   157      * @throws IOException if any IO errors occur
   151      * @throws TreePosTest.ParseException if any errors occur while parsing the file
   158      * @throws TreePosTest.ParseException if any errors occur while parsing the file
   152      */
   159      */
   153     JCCompilationUnit read(File file) throws IOException, ParseException {
   160     JCCompilationUnit read(File file) throws IOException, ParseException {
   154         StringWriter sw = new StringWriter();
       
   155         PrintWriter pw = new PrintWriter(sw);
       
   156         Reporter r = new Reporter(pw);
       
   157         JavacTool tool = JavacTool.create();
   161         JavacTool tool = JavacTool.create();
   158         StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null);
   162         r.errors = 0;
   159         Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file);
   163         Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file);
   160         JavacTask task = tool.getTask(pw, fm, r, Collections.<String>emptyList(), null, files);
   164         JavacTask task = tool.getTask(pw, fm, r, Collections.<String>emptyList(), null, files);
   161         Iterable<? extends CompilationUnitTree> trees = task.parse();
   165         Iterable<? extends CompilationUnitTree> trees = task.parse();
   162         pw.flush();
   166         pw.flush();
   163         if (r.errors > 0)
   167         if (r.errors > 0)