• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DocCommentTree类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.source.doctree.DocCommentTree的典型用法代码示例。如果您正苦于以下问题:Java DocCommentTree类的具体用法?Java DocCommentTree怎么用?Java DocCommentTree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DocCommentTree类属于com.sun.source.doctree包,在下文中一共展示了DocCommentTree类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:VeryPretty.java


示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:CasualDiff.java


示例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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:ModuleInfoTreeAccess.java


示例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];
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:DocTreePathHandle.java


示例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;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:FindLocalUsagesQuery.java


示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:FindLocalUsagesQuery.java


示例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;
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:InlineTagsWithBraces.java


示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:Analyzer.java


示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:RemoveTagFix.java


示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:Env.java


示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:Env.java


示例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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:ModuleInfoTreeAccess.java


示例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");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:Test.java


示例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));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:ElementJavadoc.java


示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ImmutableDocTreeTranslator.java


示例16: printPrecedingComments

import com.sun.source.doctree.DocCommentTree; //导入依赖的package包/类
private void printPrecedingComments(JCTree tree, boolean printWhitespace) {
    if (!precedingCommentsHandled.add(tree)) {
        return;
    }
    CommentSet commentSet = commentHandler.getComments(tree);
    java.util.List<Comment> pc = commentSet.getComments(CommentSet.RelativePosition.PRECEDING);
    DocCommentTree doc = tree2Doc.get(tree);
    if (!pc.isEmpty()) {
        Comment javadoc = null;
        for (Comment comment : pc) {
            if(comment.style() == Style.JAVADOC) {
                javadoc = comment;
            }
        }
        for (Comment c : pc) {
            if(doc != null && c == javadoc) {
                print((DCTree)doc);
                doc = null;
            } else {
                printComment(c, true, printWhitespace);
            }
        }
    }
    if(doc!=null) {
        print((DCTree)doc);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:VeryPretty.java


示例17: getDocComment

import com.sun.source.doctree.DocCommentTree; //导入依赖的package包/类
private DocCommentTree getDocComment(JCTree t, boolean old) {
    if (t instanceof FieldGroupTree) {
        FieldGroupTree fgt = (FieldGroupTree)t;
        List<JCVariableDecl> vars = fgt.getVariables();
        t = vars.get(0);
    }
    return old ?  oldTopLevel.docComments.getCommentTree(t) : tree2Doc.get(t);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:CasualDiff.java


示例18: diffPrecedingComments

import com.sun.source.doctree.DocCommentTree; //导入依赖的package包/类
protected int diffPrecedingComments(JCTree oldT, JCTree newT, int oldTreeStartPos, int localPointer, boolean doNotDelete) {
    if (parent instanceof FieldGroupTree) {
        FieldGroupTree fgt = (FieldGroupTree)parent;
        if (!fgt.getVariables().isEmpty() && fgt.getVariables().get(0) == oldT) {
            return localPointer;
        }
    }
    CommentSet cs = getCommentsForTree(newT, true);
    CommentSet old = getCommentsForTree(oldT, true);
    List<Comment> oldPrecedingComments = cs == old ? ((CommentSetImpl)cs).getOrigComments(CommentSet.RelativePosition.PRECEDING) : old.getComments(CommentSet.RelativePosition.PRECEDING);
    List<Comment> newPrecedingComments = cs.getComments(CommentSet.RelativePosition.PRECEDING);
    DocCommentTree newD = getDocComment(newT, false);
    if (sameComments(oldPrecedingComments, newPrecedingComments) && newD == null) {
        if (oldPrecedingComments.isEmpty()) {
            return localPointer;
        }
        int newP = oldPrecedingComments.get(oldPrecedingComments.size() - 1).endPos();
        if (newP > localPointer && newP < oldTreeStartPos) {
            copyTo(localPointer, newP);
            return newP;
        } else {
            return localPointer;
        }
        
    }
    DocCommentTree oldD = getDocComment(oldT, true);
    return diffCommentLists(oldTreeStartPos, oldPrecedingComments, newPrecedingComments, oldD, newD, false, true, false,
            doNotDelete,
            localPointer);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:CasualDiff.java


示例19: resolve

import com.sun.source.doctree.DocCommentTree; //导入依赖的package包/类
public DocTreePath resolve(CompilationInfo javac) throws IllegalArgumentException {
    TreePath p = parent.resolve(javac);

    if (p == null) {
        return null;
    }
    
    DocCommentTree docCommentTree = javac.getDocTrees().getDocCommentTree(p);
    return new DocTreePath(p, docCommentTree);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:DocTreePathHandle.java


示例20: runDocTreePath

import com.sun.source.doctree.DocCommentTree; //导入依赖的package包/类
/**
 * Tests DocTrees.getDocTreePath(PackageElement p, FileObject fo).
 *
 * @param javaFileName the java anchor file
 * @param pkgFileName the package file name
 * @throws Exception e if something goes awry
 */
public void runDocTreePath(String javaFileName, String pkgFileName) throws Exception  {
    List<File> javaFiles = new ArrayList<>();
    javaFiles.add(new File(testSrc, javaFileName));

    List<File> dirs = new ArrayList<>();
    dirs.add(new File(testSrc));

    try (StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null)) {
        fm.setLocation(javax.tools.StandardLocation.SOURCE_PATH, dirs);
        Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(javaFiles);

        final JavacTask t = javac.getTask(null, fm, null, null, null, fos);
        final DocTrees trees = DocTrees.instance(t);
        final Elements elementUtils = t.getElements();

        Iterable<? extends Element> elements = t.analyze();

        Element klass = elements.iterator().next();
        PackageElement pkg = elementUtils.getPackageOf(klass);

        FileObject htmlFo = fm.getFileForInput(javax.tools.StandardLocation.SOURCE_PATH,
                t.getElements().getPackageOf(klass).getQualifiedName().toString(),
                "package.html");
        System.out.println();
        DocTreePath treePath = trees.getDocTreePath(htmlFo, pkg);
        DocCommentTree dcTree = treePath.getDocComment();

        StringWriter sw = new StringWriter();
        printer.print(dcTree, sw);
        String found = sw.toString();

        String expected = getExpected(htmlFo.openReader(true));
        astcheck(pkgFileName, expected, found);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:43,代码来源:DocCommentTreeApiTester.java



注:本文中的com.sun.source.doctree.DocCommentTree类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java UpdatePipelineResponseProto类代码示例发布时间:2022-05-22
下一篇:
Java DoubleStringConverter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap