本文整理汇总了Java中com.sun.source.doctree.DocCommentTree类的典型用法代码示例。如果您正苦于以下问题:Java DocCommentTree类的具体用法?Java DocCommentTree怎么用?Java DocCommentTree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocCommentTree类属于com.sun.source.doctree包,在下文中一共展示了DocCommentTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: VeryPretty
import com.sun.source.doctree.DocCommentTree; //导入依赖的package包/类
private VeryPretty(Context context, CodeStyle cs, Map<Tree, ?> tree2Tag, Map<Tree, DocCommentTree> tree2Doc, Map<?, int[]> tag2Span, String origText) {
names = Names.instance(context);
enclClass = null;
commentHandler = CommentHandlerService.instance(context);
operators = Operators.instance(context);
widthEstimator = new WidthEstimator(context);
danglingElseChecker = new DanglingElseChecker();
prec = TreeInfo.notExpression;
this.cs = cs;
out = new CharBuffer(cs.getRightMargin(), cs.getTabSize(), cs.expandTabToSpaces());
out.addTrimObserver(this);
this.indentSize = cs.getIndentSize();
this.tree2Tag = tree2Tag;
this.tree2Doc = tree2Doc == null ? Collections.EMPTY_MAP : tree2Doc;
this.tag2Span = (Map<Object, int[]>) tag2Span;//XXX
this.origText = origText;
this.comments = CommentHandlerService.instance(context);
}
示例2: CasualDiff
import com.sun.source.doctree.DocCommentTree; //导入依赖的package包/类
protected CasualDiff(Context context, DiffContext diffContext, TreeUtilities treeUtilities, Map<Tree, ?> tree2Tag, Map<Tree, DocCommentTree> tree2Doc, Map<?, int[]> tag2Span, Set<Tree> oldTrees) {
diffs = new LinkedHashSet<Diff>();
comments = CommentHandlerService.instance(context);
this.treeUtilities = treeUtilities;
this.diffContext = diffContext;
this.tokenSequence = diffContext.tokenSequence;
this.origText = diffContext.origText;
this.context = context;
this.names = Names.instance(context);
this.tree2Tag = tree2Tag;
this.tree2Doc = tree2Doc;
this.tag2Span = (Map<Object, int[]>) tag2Span;//XXX
printer = new VeryPretty(diffContext, diffContext.style, tree2Tag, tree2Doc, tag2Span, origText);
printer.oldTrees = oldTrees;
this.oldTrees = oldTrees;
}
示例3: testTreePathForModuleDecl
import com.sun.source.doctree.DocCommentTree; //导入依赖的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);
}
}
示例4: getChild
import com.sun.source.doctree.DocCommentTree; //导入依赖的package包/类
private static DocTreePath getChild(@NonNull DocCommentTree t, final int index) {
final DocTreePath[] result = new DocTreePath[1];
t.accept(new DocTreePathScanner<DocTreePath, Void>() {
int count = 0;
@Override
public DocTreePath scan(DocTree node, Void p) {
if(index == count) {
result[0] = getCurrentPath();
}
return null;
}
}, null);
return result[0];
}
示例5: handleJavadoc
import com.sun.source.doctree.DocCommentTree; //导入依赖的package包/类
private void handleJavadoc(TreePath el) {
if(el != null) {
switch(el.getLeaf().getKind()) {
case METHOD:
case ANNOTATION_TYPE:
case CLASS:
case ENUM:
case INTERFACE:
case VARIABLE:
DocCommentTree docCommentTree = info.getDocTrees().getDocCommentTree(el);
if(docCommentTree != null) {
DocTreePath docTreePath = new DocTreePath(el, docCommentTree);
docScanner.scan(docTreePath, null);
}
default:
break;
}
}
}
示例6: visitIdentifier
import com.sun.source.doctree.DocCommentTree; //导入依赖的package包/类
@Override
public DocTree visitIdentifier(com.sun.source.doctree.IdentifierTree node, Element p) {
DocTrees trees = info.getDocTrees();
Element el = trees.getElement(getCurrentPath());
if (el != null && el.equals(toFind)) {
DocSourcePositions sp = trees.getSourcePositions();
CompilationUnitTree cut = info.getCompilationUnit();
DocCommentTree docComment = getCurrentPath().getDocComment();
long start = sp.getStartPosition(cut, docComment, node);
long end = sp.getEndPosition(cut, docComment, node);
if(start != Diagnostic.NOPOS && end != Diagnostic.NOPOS) {
try {
MutablePositionRegion region = createRegion(doc, (int)start, (int)end);
usages.add(region);
} catch (BadLocationException ex) {
Exceptions.printStackTrace(ex);
}
}
}
return super.visitIdentifier(node, p);
}
示例7: run
import com.sun.source.doctree.DocCommentTree; //导入依赖的package包/类
public boolean run(DocletEnvironment root) {
DocTrees trees = root.getDocTrees();
TypeElement cd = ElementFilter.typesIn(root.getIncludedElements()).iterator().next();
DocCommentTree docCommentTree = trees.getDocCommentTree(cd);
List<? extends DocTree> tags = docCommentTree.getBody();
for (int i = 0; i < tags.size(); i++) {
System.out.println(tags.get(0).getKind());
// if (!tags[i].name().equals(expectedTags[i]) ||
// !tags[i].text().equals(expectedText[i])) {
// throw new Error("Tag \"" + tags[i] + "\" not as expected");
// }
}
return true;
}
示例8: visitDocComment
import com.sun.source.doctree.DocCommentTree; //导入依赖的package包/类
@Override
public Void visitDocComment(DocCommentTree node, List<ErrorDescription> errors) {
DocTreePath currentDocPath = getCurrentPath();
Void value = super.visitDocComment(node, errors);
DocSourcePositions sp = (DocSourcePositions) javac.getTrees().getSourcePositions();
while (!tagStack.isEmpty()) {
StartElementTree startTree = tagStack.pop();
Name tagName = startTree.getName();
HtmlTag tag = HtmlTag.get(tagName);
if (tag.endKind == HtmlTag.EndKind.REQUIRED) {
int s = (int) sp.getStartPosition(javac.getCompilationUnit(), currentDocPath.getDocComment(), startTree);
int e = (int) sp.getEndPosition(javac.getCompilationUnit(), currentDocPath.getDocComment(), startTree);
errors.add(ErrorDescriptionFactory.forSpan(ctx, s, e, TAG_START_UNMATCHED(tagName)));
}
}
return value;
}
示例9: performRewrite
import com.sun.source.doctree.DocCommentTree; //导入依赖的package包/类
@Override
protected void performRewrite(TransformationContext ctx) throws Exception {
WorkingCopy javac = ctx.getWorkingCopy();
DocTreePath path = dtph.resolve(javac);
if(path == null) {
LOG.log(Level.WARNING, "Cannot resolve DocTreePathHandle: {0}", dtph);
return;
}
DocCommentTree docComment = path.getDocComment();
TreeMaker make = javac.getTreeMaker();
final List<DocTree> blockTags = new LinkedList<DocTree>();
for (DocTree docTree : docComment.getBlockTags()) {
if (docTree != path.getLeaf()) {
blockTags.add(docTree);
}
}
DocCommentTree newDoc = make.DocComment(docComment.getFirstSentence(), docComment.getBody(), blockTags);
Tree tree = ctx.getPath().getLeaf();
javac.rewrite(tree, docComment, newDoc);
}
示例10: setCurrent
import com.sun.source.doctree.DocCommentTree; //导入依赖的package包/类
/** Set the current declaration and its doc comment. */
void setCurrent(TreePath path, DocCommentTree comment) {
currPath = path;
currDocComment = comment;
currElement = trees.getElement(currPath);
currOverriddenMethods = ((JavacTypes) types).getOverriddenMethods(currElement);
AccessKind ak = AccessKind.PUBLIC;
for (TreePath p = path; p != null; p = p.getParentPath()) {
Element e = trees.getElement(p);
if (e != null && e.getKind() != ElementKind.PACKAGE) {
ak = min(ak, AccessKind.of(e.getModifiers()));
}
}
currAccess = ak;
}
示例11: setCurrent
import com.sun.source.doctree.DocCommentTree; //导入依赖的package包/类
/** Set the current declaration and its doc comment. */
void setCurrent(TreePath path, DocCommentTree comment) {
currPath = path;
currDocComment = comment;
currElement = trees.getElement(currPath);
currOverriddenMethods = ((JavacTypes) types).getOverriddenMethods(currElement);
AccessKind ak = AccessKind.PUBLIC;
for (TreePath p = path; p != null; p = p.getParentPath()) {
Element e = trees.getElement(p);
if (e != null && e.getKind() != ElementKind.PACKAGE && e.getKind() != ElementKind.MODULE) {
ak = min(ak, AccessKind.of(e.getModifiers()));
}
}
currAccess = ak;
}
示例12: testTreePathForModuleDeclWithImport
import com.sun.source.doctree.DocCommentTree; //导入依赖的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);
}
}
示例13: run
import com.sun.source.doctree.DocCommentTree; //导入依赖的package包/类
public boolean run(DocletEnvironment root) {
DocTrees docTrees = root.getDocTrees();
System.out.println("classes:" + ElementFilter.typesIn(root.getIncludedElements()));
Element klass = ElementFilter.typesIn(root.getIncludedElements()).iterator().next();
String text = "";
try {
DocCommentTree dcTree = docTrees.getDocCommentTree(klass, overviewpath);
text = dcTree.getFullBody().toString();
} catch (IOException ioe) {
throw new Error(ioe);
}
if (text.length() < 64)
System.err.println("text: '" + text + "'");
else
System.err.println("text: '"
+ text.substring(0, 20)
+ "..."
+ text.substring(text.length() - 20)
+ "'");
return text.startsWith("ABC") && text.endsWith("XYZ");
}
示例14: appendReference
import com.sun.source.doctree.DocCommentTree; //导入依赖的package包/类
private void appendReference(StringBuilder sb, ReferenceTree ref, List<? extends DocTree> label, TreePath docPath, DocCommentTree doc, DocTrees trees) {
String sig = ref.getSignature();
if (sig != null && sig.length() > 0) {
if (sig.charAt(0) == '#') { //NOI18N
sig = sig.substring(1);
}
sig = sig.replace('#', '.'); //NOI18N
}
Element element = trees.getElement(DocTreePath.getPath(docPath, doc, ref));
if (element != null) {
createLink(sb, element, label == null || label.isEmpty() ? sig : inlineTags(label, docPath, doc, trees, null)); //NOI18N
} else {
sb.append(label == null || label.isEmpty() ? sig : inlineTags(label, docPath, doc, trees, null));
}
}
示例15: rewriteChildren
import com.sun.source.doctree.DocCommentTree; //导入依赖的package包/类
protected final DocCommentTree rewriteChildren(DocCommentTree tree) {
DocCommentTree value = tree;
List<? extends DocTree> fullBody = translateDoc(tree.getFullBody());
List<? extends DocTree> blockTags = translateDoc(tree.getBlockTags());
if (fullBody != tree.getFullBody()|| blockTags != tree.getBlockTags()) {
value = make.DocComment(fullBody, blockTags);
}
return value;
}