com.sun.tools.javac.tree.DCTree.DCDocComment Java Examples

The following examples show how to use com.sun.tools.javac.tree.DCTree.DCDocComment. 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 File: DocCommentParser.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public DCDocComment parse() {
    String c = comment.getText();
    buf = new char[c.length() + 1];
    c.getChars(0, c.length(), buf, 0);
    buf[buf.length - 1] = EOI;
    buflen = buf.length - 1;
    bp = -1;
    nextChar();

    List<DCTree> body = blockContent();
    List<DCTree> tags = blockTags();
    int pos = !body.isEmpty()
            ? body.head.pos
            : !tags.isEmpty() ? tags.head.pos : Position.NOPOS;

    DCDocComment dc = m.at(pos).newDocCommentTree(comment, body, tags);
    return dc;
}
 
Example #2
Source File: DocCommentParser.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public DCDocComment parse() {
    String c = comment.getText();
    buf = new char[c.length() + 1];
    c.getChars(0, c.length(), buf, 0);
    buf[buf.length - 1] = EOI;
    buflen = buf.length - 1;
    bp = -1;
    nextChar();

    List<DCTree> body = blockContent();
    List<DCTree> tags = blockTags();
    int pos = !body.isEmpty()
            ? body.head.pos
            : !tags.isEmpty() ? tags.head.pos : Position.NOPOS;

    DCDocComment dc = m.at(pos).newDocCommentTree(comment, body, tags);
    return dc;
}
 
Example #3
Source File: DocCommentTester.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
void check(TreePath path, Name name) throws Exception {
    JavaFileObject fo = path.getCompilationUnit().getSourceFile();
    final CharSequence cs = fo.getCharContent(true);

    final DCDocComment dc = (DCDocComment) trees.getDocCommentTree(path);
    DCTree t = (DCTree) trees.getDocCommentTree(path);

    DocTreeScanner scanner = new DocTreeScanner<Void,Void>() {
        @Override
        public Void scan(DocTree node, Void ignore) {
            if (node != null) {
                try {
                    String expect = getExpectText(node);
                    long pos = ((DCTree) node).getSourcePosition(dc);
                    String found = getFoundText(cs, (int) pos, expect.length());
                    if (!found.equals(expect)) {
                        System.err.println("expect: " + expect);
                        System.err.println("found:  " + found);
                        error("mismatch");
                    }

                } catch (StringIndexOutOfBoundsException e) {
                    error(node.getClass() + ": " + e.toString());
                        e.printStackTrace();
                }
            }
            return super.scan(node, ignore);
        }
    };

    scanner.scan(t, null);
}
 
Example #4
Source File: DocCommentTester.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
void check(TreePath path, Name name) throws Exception {
    JavaFileObject fo = path.getCompilationUnit().getSourceFile();
    final CharSequence cs = fo.getCharContent(true);

    final DCDocComment dc = (DCDocComment) trees.getDocCommentTree(path);
    DCTree t = (DCTree) trees.getDocCommentTree(path);

    DocTreeScanner scanner = new DocTreeScanner<Void,Void>() {
        @Override
        public Void scan(DocTree node, Void ignore) {
            if (node != null) {
                try {
                    String expect = getExpectText(node);
                    long pos = ((DCTree) node).getSourcePosition(dc);
                    String found = getFoundText(cs, (int) pos, expect.length());
                    if (!found.equals(expect)) {
                        System.err.println("expect: " + expect);
                        System.err.println("found:  " + found);
                        error("mismatch");
                    }

                } catch (StringIndexOutOfBoundsException e) {
                    error(node.getClass() + ": " + e.toString());
                        e.printStackTrace();
                }
            }
            return super.scan(node, ignore);
        }
    };

    scanner.scan(t, null);
}
 
Example #5
Source File: LazyDocCommentTable.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public DCDocComment getCommentTree(JCTree tree) {
    Entry e = table.get(tree);
    if (e == null)
        return null;
    if (e.tree == null)
        e.tree = new DocCommentParser(fac, diagSource, e.comment).parse();
    return e.tree;
}
 
Example #6
Source File: DocCommentTester.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
void check(TreePath path, Name name) throws Exception {
    JavaFileObject fo = path.getCompilationUnit().getSourceFile();
    final CharSequence cs = fo.getCharContent(true);

    final DCDocComment dc = (DCDocComment) trees.getDocCommentTree(path);
    DCTree t = (DCTree) trees.getDocCommentTree(path);

    DocTreeScanner scanner = new DocTreeScanner<Void,Void>() {
        @Override
        public Void scan(DocTree node, Void ignore) {
            if (node != null) {
                try {
                    String expect = getExpectText(node);
                    long pos = ((DCTree) node).getSourcePosition(dc);
                    String found = getFoundText(cs, (int) pos, expect.length());
                    if (!found.equals(expect)) {
                        System.err.println("expect: " + expect);
                        System.err.println("found:  " + found);
                        error("mismatch");
                    }

                } catch (StringIndexOutOfBoundsException e) {
                    error(node.getClass() + ": " + e.toString());
                        e.printStackTrace();
                }
            }
            return super.scan(node, ignore);
        }
    };

    scanner.scan(t, null);
}
 
Example #7
Source File: LazyDocCommentTable.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public DCDocComment getCommentTree(JCTree tree) {
    Entry e = table.get(tree);
    if (e == null)
        return null;
    if (e.tree == null)
        e.tree = new DocCommentParser(fac, diagSource, e.comment).parse();
    return e.tree;
}
 
Example #8
Source File: DocCommentTester.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
void check(TreePath path, Name name) throws Exception {
    JavaFileObject fo = path.getCompilationUnit().getSourceFile();
    final CharSequence cs = fo.getCharContent(true);

    final DCDocComment dc = (DCDocComment) trees.getDocCommentTree(path);
    DCTree t = (DCTree) trees.getDocCommentTree(path);

    DocTreeScanner scanner = new DocTreeScanner<Void,Void>() {
        @Override
        public Void scan(DocTree node, Void ignore) {
            if (node != null) {
                try {
                    String expect = getExpectText(node);
                    long pos = ((DCTree) node).getSourcePosition(dc);
                    String found = getFoundText(cs, (int) pos, expect.length());
                    if (!found.equals(expect)) {
                        System.err.println("expect: " + expect);
                        System.err.println("found:  " + found);
                        error("mismatch");
                    }

                } catch (StringIndexOutOfBoundsException e) {
                    error(node.getClass() + ": " + e.toString());
                        e.printStackTrace();
                }
            }
            return super.scan(node, ignore);
        }
    };

    scanner.scan(t, null);
}
 
Example #9
Source File: LazyDocCommentTable.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public DCDocComment getCommentTree(JCTree tree) {
    Entry e = table.get(tree);
    if (e == null)
        return null;
    if (e.tree == null)
        e.tree = new DocCommentParser(fac, diagSource, e.comment).parse();
    return e.tree;
}
 
Example #10
Source File: DocCommentTester.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
void check(TreePath path, Name name) throws Exception {
    JavaFileObject fo = path.getCompilationUnit().getSourceFile();
    final CharSequence cs = fo.getCharContent(true);

    final DCDocComment dc = (DCDocComment) trees.getDocCommentTree(path);
    DCTree t = (DCTree) trees.getDocCommentTree(path);

    DocTreeScanner scanner = new DocTreeScanner<Void,Void>() {
        @Override
        public Void scan(DocTree node, Void ignore) {
            if (node != null) {
                try {
                    String expect = getExpectText(node);
                    long pos = ((DCTree) node).getSourcePosition(dc);
                    String found = getFoundText(cs, (int) pos, expect.length());
                    if (!found.equals(expect)) {
                        System.err.println("expect: " + expect);
                        System.err.println("found:  " + found);
                        error("mismatch");
                    }

                } catch (StringIndexOutOfBoundsException e) {
                    error(node.getClass() + ": " + e.toString());
                        e.printStackTrace();
                }
            }
            return super.scan(node, ignore);
        }
    };

    scanner.scan(t, null);
}
 
Example #11
Source File: JavacTrees.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@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 #12
Source File: DocTreeMaker.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override @DefinedBy(Api.COMPILER_TREE)
public DCDocComment newDocCommentTree(List<? extends DocTree> fullBody, List<? extends DocTree> tags) {
    ListBuffer<DCTree> lb = new ListBuffer<>();
    lb.addAll(cast(fullBody));
    List<DCTree> fBody = lb.toList();

    // A dummy comment to keep the diagnostics logic happy.
    Comment c = new Comment() {
        @Override
        public String getText() {
            return null;
        }

        @Override
        public int getSourcePos(int index) {
            return Position.NOPOS;
        }

        @Override
        public CommentStyle getStyle() {
            return CommentStyle.JAVADOC;
        }

        @Override
        public boolean isDeprecated() {
            return false;
        }
    };
    Pair<List<DCTree>, List<DCTree>> pair = splitBody(fullBody);
    DCDocComment tree = new DCDocComment(c, fBody, pair.fst, pair.snd, cast(tags));
    return tree;
}
 
Example #13
Source File: LazyDocCommentTable.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public DCDocComment getCommentTree(JCTree tree) {
    Entry e = table.get(tree);
    if (e == null)
        return null;
    if (e.tree == null)
        e.tree = new DocCommentParser(fac, diagSource, e.comment).parse();
    return e.tree;
}
 
Example #14
Source File: LazyDocCommentTable.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public DCDocComment getCommentTree(JCTree tree) {
    Entry e = table.get(tree);
    if (e == null)
        return null;
    if (e.tree == null)
        e.tree = new DocCommentParser(fac, diagSource, e.comment).parse();
    return e.tree;
}
 
Example #15
Source File: LazyDocCommentTable.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public DCDocComment getCommentTree(JCTree tree) {
    Entry e = table.get(tree);
    if (e == null)
        return null;
    if (e.tree == null)
        e.tree = new DocCommentParser(fac, diagSource, e.comment).parse();
    return e.tree;
}
 
Example #16
Source File: JavacTrees.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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 #17
Source File: DocTreeMaker.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override @DefinedBy(Api.COMPILER_TREE)
public DCDocComment newDocCommentTree(List<? extends DocTree> fullBody, List<? extends DocTree> tags) {
    ListBuffer<DCTree> lb = new ListBuffer<>();
    lb.addAll(cast(fullBody));
    List<DCTree> fBody = lb.toList();

    // A dummy comment to keep the diagnostics logic happy.
    Comment c = new Comment() {
        @Override
        public String getText() {
            return null;
        }

        @Override
        public int getSourcePos(int index) {
            return Position.NOPOS;
        }

        @Override
        public CommentStyle getStyle() {
            return CommentStyle.JAVADOC;
        }

        @Override
        public boolean isDeprecated() {
            return false;
        }
    };
    Pair<List<DCTree>, List<DCTree>> pair = splitBody(fullBody);
    DCDocComment tree = new DCDocComment(c, fBody, pair.fst, pair.snd, cast(tags));
    return tree;
}
 
Example #18
Source File: DocCommentTester.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
void check(TreePath path, Name name) throws Exception {
    JavaFileObject fo = path.getCompilationUnit().getSourceFile();
    final CharSequence cs = fo.getCharContent(true);

    final DCDocComment dc = (DCDocComment) trees.getDocCommentTree(path);
    DCTree t = (DCTree) trees.getDocCommentTree(path);

    DocTreeScanner scanner = new DocTreeScanner<Void,Void>() {
        @Override
        public Void scan(DocTree node, Void ignore) {
            if (node != null) {
                try {
                    String expect = getExpectText(node);
                    long pos = ((DCTree) node).getSourcePosition(dc);
                    String found = getFoundText(cs, (int) pos, expect.length());
                    if (!found.equals(expect)) {
                        System.err.println("expect: " + expect);
                        System.err.println("found:  " + found);
                        error("mismatch");
                    }

                } catch (StringIndexOutOfBoundsException e) {
                    error(node.getClass() + ": " + e.toString());
                        e.printStackTrace();
                }
            }
            return super.scan(node, ignore);
        }
    };

    scanner.scan(t, null);
}
 
Example #19
Source File: LazyDocCommentTable.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public DCDocComment getCommentTree(JCTree tree) {
    Entry e = table.get(tree);
    if (e == null)
        return null;
    if (e.tree == null)
        e.tree = new DocCommentParser(fac, diagSource, e.comment).parse();
    return e.tree;
}
 
Example #20
Source File: DocCommentTester.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
void check(TreePath path, Name name) throws Exception {
    JavaFileObject fo = path.getCompilationUnit().getSourceFile();
    final CharSequence cs = fo.getCharContent(true);

    final DCDocComment dc = (DCDocComment) trees.getDocCommentTree(path);
    DCTree t = (DCTree) trees.getDocCommentTree(path);

    DocTreeScanner scanner = new DocTreeScanner<Void,Void>() {
        @Override
        public Void scan(DocTree node, Void ignore) {
            if (node != null) {
                try {
                    String expect = getExpectText(node);
                    long pos = ((DCTree) node).getSourcePosition(dc);
                    String found = getFoundText(cs, (int) pos, expect.length());
                    if (!found.equals(expect)) {
                        System.err.println("expect: " + expect);
                        System.err.println("found:  " + found);
                        error("mismatch");
                    }

                } catch (StringIndexOutOfBoundsException e) {
                    error(node.getClass() + ": " + e.toString());
                        e.printStackTrace();
                }
            }
            return super.scan(node, ignore);
        }
    };

    scanner.scan(t, null);
}
 
Example #21
Source File: LazyDocCommentTable.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public DCDocComment getCommentTree(JCTree tree) {
    Entry e = table.get(tree);
    if (e == null)
        return null;
    if (e.tree == null)
        e.tree = new DocCommentParser(fac, diagSource, e.comment).parse();
    return e.tree;
}
 
Example #22
Source File: LazyDocCommentTable.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public DCDocComment getCommentTree(JCTree tree) {
    Entry e = table.get(tree);
    if (e == null)
        return null;
    if (e.tree == null)
        e.tree = new DocCommentParser(fac, diagSource, e.comment).parse();
    return e.tree;
}
 
Example #23
Source File: DocCommentTester.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
void check(TreePath path, Name name) throws Exception {
    JavaFileObject fo = path.getCompilationUnit().getSourceFile();
    final CharSequence cs = fo.getCharContent(true);

    final DCDocComment dc = (DCDocComment) trees.getDocCommentTree(path);
    DCTree t = (DCTree) trees.getDocCommentTree(path);

    DocTreeScanner scanner = new DocTreeScanner<Void,Void>() {
        @Override
        public Void scan(DocTree node, Void ignore) {
            if (node != null) {
                try {
                    String expect = getExpectText(node);
                    long pos = ((DCTree) node).getSourcePosition(dc);
                    String found = getFoundText(cs, (int) pos, expect.length());
                    if (!found.equals(expect)) {
                        System.err.println("expect: " + expect);
                        System.err.println("found:  " + found);
                        error("mismatch");
                    }

                } catch (StringIndexOutOfBoundsException e) {
                    error(node.getClass() + ": " + e.toString());
                        e.printStackTrace();
                }
            }
            return super.scan(node, ignore);
        }
    };

    scanner.scan(t, null);
}
 
Example #24
Source File: DocTreeMaker.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public DCDocComment newDocCommentTree(Comment comment, List<? extends DocTree> fullBody, List<? extends DocTree> tags) {
    Pair<List<DCTree>, List<DCTree>> pair = splitBody(fullBody);
    DCDocComment tree = new DCDocComment(comment, cast(fullBody), pair.fst, pair.snd, cast(tags));
    tree.pos = pos;
    return tree;
}
 
Example #25
Source File: JavacTrees.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
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 #26
Source File: JavacTrees.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
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 #27
Source File: JavacTrees.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
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 #28
Source File: JavacTrees.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
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 #29
Source File: JavacTrees.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
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 #30
Source File: PoorDocCommentTable.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public DCDocComment getCommentTree(JCTree tree) {
    return null; // no need for generator purposes, Pretty does not call it
}