本文整理汇总了Java中com.sun.tools.javac.api.JavacTrees.getDocCommentTree方法的典型用法代码示例。如果您正苦于以下问题:Java JavacTrees.getDocCommentTree方法的具体用法?Java JavacTrees.getDocCommentTree怎么用?Java JavacTrees.getDocCommentTree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.api.JavacTrees
的用法示例。
在下文中一共展示了JavacTrees.getDocCommentTree方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTreePathForModuleDecl
import com.sun.tools.javac.api.JavacTrees; //导入方法依赖的package包/类
@Test
public void testTreePathForModuleDecl(Path base) throws Exception {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
Path src = base.resolve("src");
tb.writeJavaFiles(src, "/** Test module */ module m1x {}");
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(findJavaFiles(src));
JavacTask task = (JavacTask) compiler.getTask(null, fm, null, null, null, files);
task.analyze();
JavacTrees trees = JavacTrees.instance(task);
ModuleElement mdle = (ModuleElement) task.getElements().getModuleElement("m1x");
TreePath path = trees.getPath(mdle);
assertNotNull("path", path);
ModuleElement mdle1 = (ModuleElement) trees.getElement(path);
assertNotNull("mdle1", mdle1);
DocCommentTree docCommentTree = trees.getDocCommentTree(mdle);
assertNotNull("docCommentTree", docCommentTree);
}
}
示例2: testTreePathForModuleDeclWithImport
import com.sun.tools.javac.api.JavacTrees; //导入方法依赖的package包/类
@Test
public void testTreePathForModuleDeclWithImport(Path base) throws Exception {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
Path src = base.resolve("src");
tb.writeJavaFiles(src, "import java.lang.Deprecated; /** Test module */ @Deprecated module m1x {}");
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(findJavaFiles(src));
JavacTask task = (JavacTask) compiler.getTask(null, fm, null, null, null, files);
task.analyze();
JavacTrees trees = JavacTrees.instance(task);
ModuleElement mdle = (ModuleElement) task.getElements().getModuleElement("m1x");
TreePath path = trees.getPath(mdle);
assertNotNull("path", path);
ModuleElement mdle1 = (ModuleElement) trees.getElement(path);
assertNotNull("mdle1", mdle1);
DocCommentTree docCommentTree = trees.getDocCommentTree(mdle);
assertNotNull("docCommentTree", docCommentTree);
}
}
示例3: testTreePathForModuleDecl
import com.sun.tools.javac.api.JavacTrees; //导入方法依赖的package包/类
@Test
public void testTreePathForModuleDecl(Path base) throws Exception {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
Path src = base.resolve("src");
tb.writeJavaFiles(src, "/** Test module */ module m1 {}");
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(findJavaFiles(src));
JavacTask task = (JavacTask) compiler.getTask(null, fm, null, null, null, files);
task.analyze();
JavacTrees trees = JavacTrees.instance(task);
ModuleElement mdle = (ModuleElement) task.getElements().getModuleElement("m1");
TreePath path = trees.getPath(mdle);
assertNotNull("path", path);
ModuleElement mdle1 = (ModuleElement) trees.getElement(path);
assertNotNull("mdle1", mdle1);
DocCommentTree docCommentTree = trees.getDocCommentTree(mdle);
assertNotNull("docCommentTree", docCommentTree);
}
}