Java Code Examples for com.sun.source.util.DocTrees#instance()
The following examples show how to use
com.sun.source.util.DocTrees#instance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DocTreePathScannerTest.java From hottub with GNU General Public License v2.0 | 6 votes |
void run() throws Exception { List<File> files = new ArrayList<File>(); File testSrc = new File(System.getProperty("test.src")); for (File f: testSrc.listFiles()) { if (f.isFile() && f.getName().endsWith(".java")) files.add(f); } JavacTool javac = JavacTool.create(); StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null); Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files); JavacTask t = javac.getTask(null, fm, null, null, null, fos); DocTrees trees = DocTrees.instance(t); Iterable<? extends CompilationUnitTree> units = t.parse(); DeclScanner ds = new DeclScanner(trees); for (CompilationUnitTree unit: units) { ds.scan(unit, null); } if (errors > 0) throw new Exception(errors + " errors occurred"); }
Example 2
Source File: DocTreePathScannerTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
void run() throws Exception { List<File> files = new ArrayList<File>(); File testSrc = new File(System.getProperty("test.src")); for (File f: testSrc.listFiles()) { if (f.isFile() && f.getName().endsWith(".java")) files.add(f); } JavacTool javac = JavacTool.create(); StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null); Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files); JavacTask t = javac.getTask(null, fm, null, null, null, fos); DocTrees trees = DocTrees.instance(t); Iterable<? extends CompilationUnitTree> units = t.parse(); DeclScanner ds = new DeclScanner(trees); for (CompilationUnitTree unit: units) { ds.scan(unit, null); } if (errors > 0) throw new Exception(errors + " errors occurred"); }
Example 3
Source File: Test.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
void testTaskListener(JavacTool javac, StandardJavaFileManager fm, Iterable<? extends JavaFileObject> files, PrintWriter out, int expectedDocComments) { out.println("Test task listener"); JavacTask task = javac.getTask(out, fm, null, null, null, files); TaskListnr tl = new TaskListnr(DocTrees.instance(task)); task.addTaskListener(tl); task.call(); tl.checker.checkDocComments(expectedDocComments); }
Example 4
Source File: SimpleDocTreeVisitorTest.java From hottub with GNU General Public License v2.0 | 5 votes |
void run() throws Exception { List<File> files = new ArrayList<File>(); File testSrc = new File(System.getProperty("test.src")); for (File f: testSrc.listFiles()) { if (f.isFile() && f.getName().endsWith(".java")) files.add(f); } JavacTool javac = JavacTool.create(); StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null); Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files); JavacTask t = javac.getTask(null, fm, null, null, null, fos); DocTrees trees = DocTrees.instance(t); Iterable<? extends CompilationUnitTree> units = t.parse(); Set<DocTree.Kind> found = EnumSet.noneOf(DocTree.Kind.class); DeclScanner ds = new DeclScanner(trees, found); for (CompilationUnitTree unit: units) { ds.scan(unit, null); } for (DocTree.Kind k: DocTree.Kind.values()) { if (!found.contains(k) && k != DocTree.Kind.OTHER) error("not found: " + k); } if (errors > 0) throw new Exception(errors + " errors occurred"); }
Example 5
Source File: SimpleDocTreeVisitorTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
void run() throws Exception { List<File> files = new ArrayList<File>(); File testSrc = new File(System.getProperty("test.src")); for (File f: testSrc.listFiles()) { if (f.isFile() && f.getName().endsWith(".java")) files.add(f); } JavacTool javac = JavacTool.create(); StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null); Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files); JavacTask t = javac.getTask(null, fm, null, null, null, fos); DocTrees trees = DocTrees.instance(t); Iterable<? extends CompilationUnitTree> units = t.parse(); Set<DocTree.Kind> found = EnumSet.noneOf(DocTree.Kind.class); DeclScanner ds = new DeclScanner(trees, found); for (CompilationUnitTree unit: units) { ds.scan(unit, null); } for (DocTree.Kind k: DocTree.Kind.values()) { if (!found.contains(k) && k != DocTree.Kind.OTHER) error("not found: " + k); } if (errors > 0) throw new Exception(errors + " errors occurred"); }
Example 6
Source File: DocTreePathScannerTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
void run() throws Exception { List<File> files = new ArrayList<File>(); File testSrc = new File(System.getProperty("test.src")); for (File f: testSrc.listFiles()) { if (f.isFile() && f.getName().endsWith(".java")) files.add(f); } JavacTool javac = JavacTool.create(); try (StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null)) { Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files); JavacTask t = javac.getTask(null, fm, null, null, null, fos); DocTrees trees = DocTrees.instance(t); Iterable<? extends CompilationUnitTree> units = t.parse(); DeclScanner ds = new DeclScanner(trees); for (CompilationUnitTree unit: units) { ds.scan(unit, null); } if (errors > 0) throw new Exception(errors + " errors occurred"); } }
Example 7
Source File: Test.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
void testAnnoProcessor(JavacTool javac, StandardJavaFileManager fm, Iterable<? extends JavaFileObject> files, PrintWriter out, int expectedDocComments) { out.println("Test annotation processor"); JavacTask task = javac.getTask(out, fm, null, null, null, files); AnnoProc ap = new AnnoProc(DocTrees.instance(task)); task.setProcessors(Arrays.asList(ap)); task.call(); ap.checker.checkDocComments(expectedDocComments); }
Example 8
Source File: Test.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
void testTaskListener(JavacTool javac, StandardJavaFileManager fm, Iterable<? extends JavaFileObject> files, PrintWriter out, int expectedDocComments) { out.println("Test task listener"); JavacTask task = javac.getTask(out, fm, null, null, null, files); TaskListnr tl = new TaskListnr(DocTrees.instance(task)); task.addTaskListener(tl); task.call(); tl.checker.checkDocComments(expectedDocComments); }
Example 9
Source File: SimpleDocTreeVisitorTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
void run() throws Exception { List<File> files = new ArrayList<File>(); File testSrc = new File(System.getProperty("test.src")); for (File f: testSrc.listFiles()) { if (f.isFile() && f.getName().endsWith(".java")) files.add(f); } JavacTool javac = JavacTool.create(); StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null); Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files); JavacTask t = javac.getTask(null, fm, null, null, null, fos); DocTrees trees = DocTrees.instance(t); Iterable<? extends CompilationUnitTree> units = t.parse(); Set<DocTree.Kind> found = EnumSet.noneOf(DocTree.Kind.class); DeclScanner ds = new DeclScanner(trees, found); for (CompilationUnitTree unit: units) { ds.scan(unit, null); } for (DocTree.Kind k: DocTree.Kind.values()) { if (!found.contains(k) && k != DocTree.Kind.OTHER) error("not found: " + k); } if (errors > 0) throw new Exception(errors + " errors occurred"); }
Example 10
Source File: Test.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
void testAnnoProcessor(JavacTool javac, StandardJavaFileManager fm, Iterable<? extends JavaFileObject> files, PrintWriter out, int expectedDocComments) { out.println("Test annotation processor"); JavacTask task = javac.getTask(out, fm, null, null, null, files); AnnoProc ap = new AnnoProc(DocTrees.instance(task)); task.setProcessors(Arrays.asList(ap)); task.call(); ap.checker.checkDocComments(expectedDocComments); }
Example 11
Source File: JavadocConverter.java From j2objc with Apache License 2.0 | 5 votes |
/** Returns an AST node for the javadoc comment of a specified class, method, or field element. */ static Javadoc convertJavadoc( TreePath path, String source, JavacEnvironment env, boolean reportWarnings) { DocTrees docTrees = DocTrees.instance(env.task()); DocCommentTree docComment = docTrees.getDocCommentTree(path); if (docComment == null) { return null; // Declaration does not have a javadoc comment. } JavadocConverter converter = new JavadocConverter( env.treeUtilities().getElement(path), docComment, source, docTrees, path.getCompilationUnit(), reportWarnings); Javadoc result = new Javadoc(); // First tag is the description. TagElement newTag = new TagElement().setTagKind(TagElement.TagKind.DESCRIPTION); converter.scan(docComment.getFirstSentence(), newTag); converter.scan(docComment.getBody(), newTag); if (!newTag.getFragments().isEmpty()) { List<TreeNode> fragments = newTag.getFragments(); int start = fragments.get(0).getStartPosition(); TreeNode lastFragment = fragments.get(fragments.size() - 1); int end = start + lastFragment.getLength(); converter.setPos(newTag, start, end); result.addTag(newTag); } for (DocTree tag : docComment.getBlockTags()) { if (tag.getKind() != DocTree.Kind.ERRONEOUS) { newTag = new TagElement(); converter.scan(tag, newTag); result.addTag(newTag); } } return result; }
Example 12
Source File: Test.java From hottub with GNU General Public License v2.0 | 5 votes |
void testAnnoProcessor(JavacTool javac, StandardJavaFileManager fm, Iterable<? extends JavaFileObject> files, PrintWriter out, int expectedDocComments) { out.println("Test annotation processor"); JavacTask task = javac.getTask(out, fm, null, null, null, files); AnnoProc ap = new AnnoProc(DocTrees.instance(task)); task.setProcessors(Arrays.asList(ap)); task.call(); ap.checker.checkDocComments(expectedDocComments); }
Example 13
Source File: SimpleDocTreeVisitorTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
void run() throws Exception { List<File> files = new ArrayList<File>(); File testSrc = new File(System.getProperty("test.src")); for (File f: testSrc.listFiles()) { if (f.isFile() && f.getName().endsWith(".java")) files.add(f); } JavacTool javac = JavacTool.create(); StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null); Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files); JavacTask t = javac.getTask(null, fm, null, null, null, fos); DocTrees trees = DocTrees.instance(t); Iterable<? extends CompilationUnitTree> units = t.parse(); Set<DocTree.Kind> found = EnumSet.noneOf(DocTree.Kind.class); DeclScanner ds = new DeclScanner(trees, found); for (CompilationUnitTree unit: units) { ds.scan(unit, null); } for (DocTree.Kind k: DocTree.Kind.values()) { if (!found.contains(k) && k != DocTree.Kind.OTHER) error("not found: " + k); } if (errors > 0) throw new Exception(errors + " errors occurred"); }
Example 14
Source File: ReferenceTest.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Override public void init(ProcessingEnvironment pEnv) { super.init(pEnv); trees = DocTrees.instance(pEnv); }
Example 15
Source File: DocCommentProcessor.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Override public void init(ProcessingEnvironment pEnv) { super.init(pEnv); trees = DocTrees.instance(pEnv); messager = pEnv.getMessager(); }
Example 16
Source File: ReferenceTest.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@Override public void init(ProcessingEnvironment pEnv) { super.init(pEnv); trees = DocTrees.instance(pEnv); }
Example 17
Source File: ReferenceTest.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Override public void init(ProcessingEnvironment pEnv) { super.init(pEnv); trees = DocTrees.instance(pEnv); }
Example 18
Source File: Helper.java From vertx-docgen with Apache License 2.0 | 4 votes |
public Helper(ProcessingEnvironment env) { typeUtils = env.getTypeUtils(); elementUtils = env.getElementUtils(); docTrees = DocTrees.instance(env); }
Example 19
Source File: JavaDocGenerator.java From vertx-docgen with Apache License 2.0 | 4 votes |
@Override public void init(ProcessingEnvironment env) { docTrees = DocTrees.instance(env); processingEnv = env; }
Example 20
Source File: ReferenceTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public void init(ProcessingEnvironment pEnv) { super.init(pEnv); trees = DocTrees.instance(pEnv); }