42 import javax.tools.JavaFileManager; |
42 import javax.tools.JavaFileManager; |
43 import javax.tools.JavaFileObject; |
43 import javax.tools.JavaFileObject; |
44 |
44 |
45 import com.sun.source.util.JavacTask; |
45 import com.sun.source.util.JavacTask; |
46 import com.sun.source.util.Plugin; |
46 import com.sun.source.util.Plugin; |
|
47 import com.sun.tools.doclint.DocLint; |
|
48 import com.sun.tools.javac.api.BasicJavacTask; |
47 import com.sun.tools.javac.code.Source; |
49 import com.sun.tools.javac.code.Source; |
48 import com.sun.tools.javac.file.CacheFSInfo; |
50 import com.sun.tools.javac.file.CacheFSInfo; |
49 import com.sun.tools.javac.file.JavacFileManager; |
51 import com.sun.tools.javac.file.JavacFileManager; |
50 import com.sun.tools.javac.jvm.Target; |
52 import com.sun.tools.javac.jvm.Target; |
51 import com.sun.tools.javac.processing.AnnotationProcessingError; |
53 import com.sun.tools.javac.processing.AnnotationProcessingError; |
426 boolean batchMode = (options.isUnset("nonBatchMode") |
428 boolean batchMode = (options.isUnset("nonBatchMode") |
427 && System.getProperty("nonBatchMode") == null); |
429 && System.getProperty("nonBatchMode") == null); |
428 if (batchMode) |
430 if (batchMode) |
429 CacheFSInfo.preRegister(context); |
431 CacheFSInfo.preRegister(context); |
430 |
432 |
|
433 // FIXME: this code will not be invoked if using JavacTask.parse/analyze/generate |
431 // invoke any available plugins |
434 // invoke any available plugins |
432 String plugins = options.get(PLUGIN); |
435 String plugins = options.get(PLUGIN); |
433 if (plugins != null) { |
436 if (plugins != null) { |
434 JavacProcessingEnvironment pEnv = JavacProcessingEnvironment.instance(context); |
437 JavacProcessingEnvironment pEnv = JavacProcessingEnvironment.instance(context); |
435 ClassLoader cl = pEnv.getProcessorClassLoader(); |
438 ClassLoader cl = pEnv.getProcessorClassLoader(); |
462 for (List<String> p: pluginsToCall) { |
465 for (List<String> p: pluginsToCall) { |
463 log.printLines(PrefixKind.JAVAC, "msg.plugin.not.found", p.head); |
466 log.printLines(PrefixKind.JAVAC, "msg.plugin.not.found", p.head); |
464 } |
467 } |
465 } |
468 } |
466 |
469 |
|
470 comp = JavaCompiler.instance(context); |
|
471 |
|
472 // FIXME: this code will not be invoked if using JavacTask.parse/analyze/generate |
|
473 String xdoclint = options.get(XDOCLINT); |
|
474 String xdoclintCustom = options.get(XDOCLINT_CUSTOM); |
|
475 if (xdoclint != null || xdoclintCustom != null) { |
|
476 Set<String> doclintOpts = new LinkedHashSet<String>(); |
|
477 if (xdoclint != null) |
|
478 doclintOpts.add(DocLint.XMSGS_OPTION); |
|
479 if (xdoclintCustom != null) { |
|
480 for (String s: xdoclintCustom.split("\\s+")) { |
|
481 if (s.isEmpty()) |
|
482 continue; |
|
483 doclintOpts.add(s.replace(XDOCLINT_CUSTOM.text, DocLint.XMSGS_CUSTOM_PREFIX)); |
|
484 } |
|
485 } |
|
486 if (!(doclintOpts.size() == 1 |
|
487 && doclintOpts.iterator().next().equals(DocLint.XMSGS_CUSTOM_PREFIX + "none"))) { |
|
488 JavacTask t = BasicJavacTask.instance(context); |
|
489 new DocLint().init(t, doclintOpts.toArray(new String[doclintOpts.size()])); |
|
490 comp.keepComments = true; |
|
491 } |
|
492 } |
|
493 |
467 fileManager = context.get(JavaFileManager.class); |
494 fileManager = context.get(JavaFileManager.class); |
468 |
|
469 comp = JavaCompiler.instance(context); |
|
470 if (comp == null) return Result.SYSERR; |
|
471 |
495 |
472 if (!files.isEmpty()) { |
496 if (!files.isEmpty()) { |
473 // add filenames to fileObjects |
497 // add filenames to fileObjects |
474 comp = JavaCompiler.instance(context); |
498 comp = JavaCompiler.instance(context); |
475 List<JavaFileObject> otherFiles = List.nil(); |
499 List<JavaFileObject> otherFiles = List.nil(); |