com.sun.source.doctree.DocTree Java Examples
The following examples show how to use
com.sun.source.doctree.DocTree.
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 Project: openjdk-jdk9 Author: AdoptOpenJDK File: ModuleGraph.java License: GNU General Public License v2.0 | 6 votes |
@Override public String toString(List<? extends DocTree> tags, Element element) { if (!enableModuleGraph) { return ""; } String moduleName = ((ModuleElement) element).getQualifiedName().toString(); String imageFile = moduleName + "-graph.png"; int thumbnailHeight = -1; String hoverImage = ""; if (!moduleName.equals("java.base")) { thumbnailHeight = 100; // also appears in the stylesheet hoverImage = "<span>" + getImage(moduleName, imageFile, -1, true) + "</span>"; } return "<dt>" + "<span class=\"simpleTagLabel\">Module Graph:</span>\n" + "</dt>" + "<dd>" + "<a class=moduleGraph href=\"" + imageFile + "\">" + getImage(moduleName, imageFile, thumbnailHeight, false) + hoverImage + "</a>" + "</dd>"; }
Example #2
Source Project: jdk8u60 Author: chenghanpeng File: DocTreePath.java License: GNU General Public License v2.0 | 6 votes |
public Iterator<DocTree> iterator() { return new Iterator<DocTree>() { public boolean hasNext() { return next != null; } public DocTree next() { DocTree t = next.leaf; next = next.parent; return t; } public void remove() { throw new UnsupportedOperationException(); } private DocTreePath next = DocTreePath.this; }; }
Example #3
Source Project: openjdk-jdk8u-backup Author: AdoptOpenJDK File: ReferenceTest.java License: GNU General Public License v2.0 | 6 votes |
void checkReference(ReferenceTree tree, List<? extends DocTree> label) { String sig = tree.getSignature(); Element found = trees.getElement(new DocTreePath(getCurrentPath(), tree)); if (found == null) { System.err.println(sig + " NOT FOUND"); } else { System.err.println(sig + " found " + found.getKind() + " " + found); } String expect = "UNKNOWN"; if (label.size() > 0 && label.get(0) instanceof TextTree) expect = ((TextTree) label.get(0)).getBody(); if (!expect.equalsIgnoreCase(found == null ? "bad" : found.getKind().name())) { error(tree, "Unexpected value found: " + found +", expected: " + expect); } }
Example #4
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: DocTreePath.java License: GNU General Public License v2.0 | 6 votes |
public Iterator<DocTree> iterator() { return new Iterator<DocTree>() { public boolean hasNext() { return next != null; } public DocTree next() { DocTree t = next.leaf; next = next.parent; return t; } public void remove() { throw new UnsupportedOperationException(); } private DocTreePath next = DocTreePath.this; }; }
Example #5
Source Project: JDKSourceCode1.8 Author: wupeixuan File: DocTreePath.java License: MIT License | 6 votes |
public Iterator<DocTree> iterator() { return new Iterator<DocTree>() { public boolean hasNext() { return next != null; } public DocTree next() { DocTree t = next.leaf; next = next.parent; return t; } public void remove() { throw new UnsupportedOperationException(); } private DocTreePath next = DocTreePath.this; }; }
Example #6
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: ReferenceTest.java License: GNU General Public License v2.0 | 5 votes |
@Override public Void visitSee(SeeTree tree, Void ignore) { List<? extends DocTree> refLabel = tree.getReference(); if (refLabel.size() > 1 && (refLabel.get(0) instanceof ReferenceTree)) { ReferenceTree ref = (ReferenceTree) refLabel.get(0); List<? extends DocTree> label = refLabel.subList(1, refLabel.size()); checkReference(ref, label); } return null; }
Example #7
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: TagletWriterImpl.java License: GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ public Content propertyTagOutput(Element element, DocTree tag, String prefix) { Content body = new ContentBuilder(); CommentHelper ch = utils.getCommentHelper(element); body.addContent(new RawHtml(prefix)); body.addContent(" "); body.addContent(HtmlTree.CODE(new RawHtml(ch.getText(tag)))); body.addContent("."); Content result = HtmlTree.P(body); return result; }
Example #8
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: UserTaglet.java License: GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ public Content getTagletOutput(Element holder, TagletWriter writer) { Content output = writer.getOutputInstance(); Utils utils = writer.configuration().utils; List<? extends DocTree> tags = utils.getBlockTags(holder, getName()); if (!tags.isEmpty()) { String tagString = userTaglet.toString(tags, holder); if (tagString != null) { output.addContent(new RawHtml(tagString)); } } return output; }
Example #9
Source Project: openjdk-jdk8u-backup Author: AdoptOpenJDK File: Checker.java License: GNU General Public License v2.0 | 5 votes |
void warnIfEmpty(DocTree tree, List<? extends DocTree> list) { for (DocTree d: list) { switch (d.getKind()) { case TEXT: if (hasNonWhitespace((TextTree) d)) return; break; default: return; } } env.messages.warning(SYNTAX, tree, "dc.empty", tree.getKind().tagName); }
Example #10
Source Project: TencentKona-8 Author: Tencent File: Messages.java License: GNU General Public License v2.0 | 5 votes |
protected void report(Group group, Diagnostic.Kind dkind, DocTree tree, String code, Object... args) { if (options.isEnabled(group, env.currAccess)) { String msg = (code == null) ? (String) args[0] : localize(code, args); env.trees.printMessage(dkind, msg, tree, env.currDocComment, env.currPath.getCompilationUnit()); stats.record(group, dkind, code); } }
Example #11
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: DocCommentTreeApiTester.java License: GNU General Public License v2.0 | 5 votes |
/** * Tests getting a DocCommentTree from an element, as well * as test if break iterator setter/getter works correctly. * * @param javaFileName a test file to be processed * @param expected the expected output * @throws java.io.IOException */ public void runElementAndBreakIteratorTests(String javaFileName, String expected) throws IOException { 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); Iterable<? extends Element> elements = t.analyze(); Element klass = elements.iterator().next(); DocCommentTree dcTree = trees.getDocCommentTree(klass); List<? extends DocTree> firstSentence = dcTree.getFirstSentence(); StringWriter sw = new StringWriter(); DocPretty pretty = new DocPretty(sw); pretty.print(firstSentence); check("getDocCommentTree(Element)", expected, sw.toString()); BreakIterator bi = BreakIterator.getSentenceInstance(Locale.FRENCH); trees.setBreakIterator(bi); BreakIterator nbi = trees.getBreakIterator(); if (bi.equals(nbi)) { pass++; check("getDocCommentTree(Element) with BreakIterator", expected, sw.toString()); } else { fail++; System.err.println("BreakIterators don't match"); } } }
Example #12
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: JavacTrees.java License: GNU General Public License v2.0 | 5 votes |
private DocTree getLastChild(DocTree tree) { final DocTree[] last = new DocTree[] {null}; tree.accept(new DocTreeScanner<Void, Void>() { @Override @DefinedBy(Api.COMPILER_TREE) public Void scan(DocTree node, Void p) { if (node != null) last[0] = node; return null; } }, null); return last[0]; }
Example #13
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: Messages.java License: GNU General Public License v2.0 | 5 votes |
protected void report(Group group, Diagnostic.Kind dkind, DocTree tree, String code, Object... args) { if (options.isEnabled(group, env.currAccess)) { String msg = (code == null) ? (String) args[0] : localize(code, args); env.trees.printMessage(dkind, msg, tree, env.currDocComment, env.currPath.getCompilationUnit()); stats.record(group, dkind, code); } }
Example #14
Source Project: netbeans Author: apache File: VeryPretty.java License: Apache License 2.0 | 5 votes |
@Override public Void visitVersion(VersionTree node, Void p) { printTagName(node); print(" "); for (DocTree docTree : node.getBody()) { doAccept((DCTree)docTree); } return null; }
Example #15
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: Checker.java License: GNU General Public License v2.0 | 5 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public Void visitLink(LinkTree tree, Void ignore) { markEnclosingTag(Flag.HAS_INLINE_TAG); // simulate inline context on tag stack HtmlTag t = (tree.getKind() == DocTree.Kind.LINK) ? HtmlTag.CODE : HtmlTag.SPAN; tagStack.push(new TagStackItem(tree, t)); try { return super.visitLink(tree, ignore); } finally { tagStack.pop(); } }
Example #16
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: DocTreeMaker.java License: GNU General Public License v2.0 | 5 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public DCThrows newExceptionTree(ReferenceTree name, List<? extends DocTree> description) { // TODO: verify the reference is just to a type (not a field or method) DCThrows tree = new DCThrows(Kind.EXCEPTION, (DCReference) name, cast(description)); tree.pos = pos; return tree; }
Example #17
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: Checker.java License: GNU General Public License v2.0 | 5 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public Void visitLiteral(LiteralTree tree, Void ignore) { markEnclosingTag(Flag.HAS_INLINE_TAG); if (tree.getKind() == DocTree.Kind.CODE) { for (TagStackItem tsi: tagStack) { if (tsi.tag == HtmlTag.CODE) { env.messages.warning(HTML, tree, "dc.tag.code.within.code"); break; } } } return super.visitLiteral(tree, ignore); }
Example #18
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: Checker.java License: GNU General Public License v2.0 | 5 votes |
@Override public Void visitLiteral(LiteralTree tree, Void ignore) { markEnclosingTag(Flag.HAS_INLINE_TAG); if (tree.getKind() == DocTree.Kind.CODE) { for (TagStackItem tsi: tagStack) { if (tsi.tag == HtmlTag.CODE) { env.messages.warning(HTML, tree, "dc.tag.code.within.code"); break; } } } return super.visitLiteral(tree, ignore); }
Example #19
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: Utils.java License: GNU General Public License v2.0 | 5 votes |
public List<? extends DocTree> getBlockTags(Element element, String tagName) { DocTree.Kind kind = null; switch (tagName) { case "author": case "deprecated": case "hidden": case "param": case "return": case "see": case "serial": case "since": case "throws": case "exception": case "version": kind = DocTree.Kind.valueOf(tagName.toUpperCase()); return getBlockTags(element, kind); case "serialData": kind = SERIAL_DATA; return getBlockTags(element, kind); case "serialField": kind = SERIAL_FIELD; return getBlockTags(element, kind); default: kind = DocTree.Kind.UNKNOWN_BLOCK_TAG; break; } List<? extends DocTree> blockTags = getBlockTags(element, kind); List<DocTree> out = new ArrayList<>(); String tname = tagName.startsWith("@") ? tagName.substring(1) : tagName; CommentHelper ch = getCommentHelper(element); for (DocTree dt : blockTags) { if (ch.getTagName(dt).equals(tname)) { out.add(dt); } } return out; }
Example #20
Source Project: netbeans Author: apache File: ImmutableDocTreeTranslator.java License: Apache License 2.0 | 5 votes |
protected final UnknownInlineTagTree rewriteChildren(UnknownInlineTagTree tree) { UnknownInlineTagTree value = tree; List<? extends DocTree> content = translateDoc(tree.getContent()); if (content != tree.getContent()) { value = make.UnknownInlineTag(((DCTree.DCUnknownInlineTag) tree).name, tree.getContent()); } return value; }
Example #21
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: CommentHelper.java License: GNU General Public License v2.0 | 5 votes |
public ReferenceTree getType(DocTree dtree) { if (dtree.getKind() == SERIAL_FIELD) { return ((SerialFieldTree)dtree).getType(); } else { return null; } }
Example #22
Source Project: netbeans Author: apache File: DocTreeNode.java License: Apache License 2.0 | 5 votes |
public DocTreeNode(CompilationInfo info, TreePath declaration, DocCommentTree docComment, DocTree tree) { super(new NodeChilren(children(info, declaration, docComment, tree))); this.info = info; this.docComment = docComment; this.tree = tree; setDisplayName(tree.getKind() + ":" + tree.toString()); }
Example #23
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: SimpleDocTreeVisitorTest.java License: 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 #24
Source Project: lua-for-android Author: qtiuto File: JavacTrees.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public void printMessage(Diagnostic.Kind kind, CharSequence msg, com.sun.source.doctree.DocTree t, com.sun.source.doctree.DocCommentTree c, com.sun.source.tree.CompilationUnitTree root) { printMessage(kind, msg, ((DCTree) t).pos((DCDocComment) c), root); }
Example #25
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: CommentHelper.java License: GNU General Public License v2.0 | 5 votes |
public TypeElement getReferencedClass(Configuration c, DocTree dtree) { Element e = getReferencedElement(c, dtree); if (e == null) { return null; } else if (c.utils.isTypeElement(e)) { return (TypeElement) e; } else if (!c.utils.isPackage(e)) { return c.utils.getEnclosingTypeElement(e); } return null; }
Example #26
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: Checker.java License: GNU General Public License v2.0 | 5 votes |
void checkAllowsText(DocTree tree) { TagStackItem top = tagStack.peek(); if (top != null && top.tree.getKind() == DocTree.Kind.START_ELEMENT && !top.tag.acceptsText()) { if (top.flags.add(Flag.REPORTED_BAD_INLINE)) { env.messages.error(HTML, tree, "dc.text.not.allowed", ((StartElementTree) top.tree).getName()); } } }
Example #27
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: Utils.java License: GNU General Public License v2.0 | 4 votes |
public boolean isEntity(DocTree doctree) { return isKind(doctree, ENTITY); }
Example #28
Source Project: lua-for-android Author: qtiuto File: DocTreeMaker.java License: BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public DCSince newSinceTree(List<? extends DocTree> text) { DCSince tree = new DCSince(cast(text)); tree.pos = pos; return tree; }
Example #29
Source Project: netbeans Author: apache File: RefactoringVisitor.java License: Apache License 2.0 | 4 votes |
/** * @since 1.47 */ @Override public DocTree visitDocRoot(DocRootTree node, Element p) { return docScanner.visitDocRoot(node, p, null); }
Example #30
Source Project: lua-for-android Author: qtiuto File: DocTreeMaker.java License: BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public DCVersion newVersionTree(List<? extends DocTree> text) { DCVersion tree = new DCVersion(cast(text)); tree.pos = pos; return tree; }