当前位置: 首页>>代码示例>>Java>>正文


Java DocCommentTree类代码示例

本文整理汇总了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);
   }
 
开发者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


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