606 |
606 |
607 /** Parse contents of file. |
607 /** Parse contents of file. |
608 * @param filename The name of the file to be parsed. |
608 * @param filename The name of the file to be parsed. |
609 */ |
609 */ |
610 @Deprecated |
610 @Deprecated |
611 public JCTree.JCCompilationUnit parse(String filename) throws IOException { |
611 public JCTree.JCCompilationUnit parse(String filename) { |
612 JavacFileManager fm = (JavacFileManager)fileManager; |
612 JavacFileManager fm = (JavacFileManager)fileManager; |
613 return parse(fm.getJavaFileObjectsFromStrings(List.of(filename)).iterator().next()); |
613 return parse(fm.getJavaFileObjectsFromStrings(List.of(filename)).iterator().next()); |
614 } |
614 } |
615 |
615 |
616 /** Parse contents of file. |
616 /** Parse contents of file. |
776 * discovery, {@code null} means that no processors were provided |
776 * discovery, {@code null} means that no processors were provided |
777 */ |
777 */ |
778 public void compile(List<JavaFileObject> sourceFileObjects, |
778 public void compile(List<JavaFileObject> sourceFileObjects, |
779 List<String> classnames, |
779 List<String> classnames, |
780 Iterable<? extends Processor> processors) |
780 Iterable<? extends Processor> processors) |
781 throws IOException // TODO: temp, from JavacProcessingEnvironment |
|
782 { |
781 { |
783 if (processors != null && processors.iterator().hasNext()) |
782 if (processors != null && processors.iterator().hasNext()) |
784 explicitAnnotationProcessingRequested = true; |
783 explicitAnnotationProcessingRequested = true; |
785 // as a JavaCompiler can only be used once, throw an exception if |
784 // as a JavaCompiler can only be used once, throw an exception if |
786 // it has been used before. |
785 // it has been used before. |
866 private List<JCClassDecl> rootClasses; |
865 private List<JCClassDecl> rootClasses; |
867 |
866 |
868 /** |
867 /** |
869 * Parses a list of files. |
868 * Parses a list of files. |
870 */ |
869 */ |
871 public List<JCCompilationUnit> parseFiles(Iterable<JavaFileObject> fileObjects) throws IOException { |
870 public List<JCCompilationUnit> parseFiles(Iterable<JavaFileObject> fileObjects) { |
872 if (shouldStop(CompileState.PARSE)) |
871 if (shouldStop(CompileState.PARSE)) |
873 return List.nil(); |
872 return List.nil(); |
874 |
873 |
875 //parse all files |
874 //parse all files |
876 ListBuffer<JCCompilationUnit> trees = lb(); |
875 ListBuffer<JCCompilationUnit> trees = lb(); |
948 * the compilation unit. |
947 * the compilation unit. |
949 * |
948 * |
950 * @param processors user provided annotation processors to bypass |
949 * @param processors user provided annotation processors to bypass |
951 * discovery, {@code null} means that no processors were provided |
950 * discovery, {@code null} means that no processors were provided |
952 */ |
951 */ |
953 public void initProcessAnnotations(Iterable<? extends Processor> processors) |
952 public void initProcessAnnotations(Iterable<? extends Processor> processors) { |
954 throws IOException { |
|
955 // Process annotations if processing is not disabled and there |
953 // Process annotations if processing is not disabled and there |
956 // is at least one Processor available. |
954 // is at least one Processor available. |
957 Options options = Options.instance(context); |
955 Options options = Options.instance(context); |
958 if (options.get("-proc:none") != null) { |
956 if (options.get("-proc:none") != null) { |
959 processAnnotations = false; |
957 processAnnotations = false; |
976 } |
974 } |
977 } |
975 } |
978 } |
976 } |
979 |
977 |
980 // TODO: called by JavacTaskImpl |
978 // TODO: called by JavacTaskImpl |
981 public JavaCompiler processAnnotations(List<JCCompilationUnit> roots) |
979 public JavaCompiler processAnnotations(List<JCCompilationUnit> roots) { |
982 throws IOException { |
|
983 return processAnnotations(roots, List.<String>nil()); |
980 return processAnnotations(roots, List.<String>nil()); |
984 } |
981 } |
985 |
982 |
986 /** |
983 /** |
987 * Process any anotations found in the specifed compilation units. |
984 * Process any anotations found in the specifed compilation units. |
988 * @param roots a list of compilation units |
985 * @param roots a list of compilation units |
989 * @return an instance of the compiler in which to complete the compilation |
986 * @return an instance of the compiler in which to complete the compilation |
990 */ |
987 */ |
991 public JavaCompiler processAnnotations(List<JCCompilationUnit> roots, |
988 public JavaCompiler processAnnotations(List<JCCompilationUnit> roots, |
992 List<String> classnames) |
989 List<String> classnames) { |
993 throws IOException { // TODO: see TEMP note in JavacProcessingEnvironment |
|
994 if (shouldStop(CompileState.PROCESS)) { |
990 if (shouldStop(CompileState.PROCESS)) { |
995 // Errors were encountered. |
991 // Errors were encountered. |
996 // If log.unrecoverableError is set, the errors were parse errors |
992 // If log.unrecoverableError is set, the errors were parse errors |
997 // or other errors during enter which cannot be fixed by running |
993 // or other errors during enter which cannot be fixed by running |
998 // any annotation processors. |
994 // any annotation processors. |