Java Code Examples for com.sun.source.doctree.DocTree#getKind()

The following examples show how to use com.sun.source.doctree.DocTree#getKind() . 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: CommentHelper.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public Element getException(Configuration c, DocTree dtree) {
    if (dtree.getKind() == THROWS || dtree.getKind() == EXCEPTION) {
        ThrowsTree tt = (ThrowsTree)dtree;
        ReferenceTree exceptionName = tt.getExceptionName();
        return getElement(c, exceptionName);
    }
    return null;
}
 
Example 2
Source File: Checker.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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 3
Source File: Checker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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 4
Source File: DocTreePath.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a DocTreePath for a child node.
 */
public DocTreePath(DocTreePath p, DocTree t) {
    if (t.getKind() == DocTree.Kind.DOC_COMMENT) {
        throw new IllegalArgumentException("Use DocTreePath(TreePath, DocCommentTree) to construct DocTreePath for a DocCommentTree.");
    } else {
        treePath = p.treePath;
        docComment = p.docComment;
        parent = p;
    }
    leaf = t;
}
 
Example 5
Source File: CommentHelper.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public IdentifierTree getName(DocTree dtree) {
    switch (dtree.getKind()) {
        case PARAM:
            return ((ParamTree)dtree).getName();
        case SERIAL_FIELD:
            return ((SerialFieldTree)dtree).getName();
        default:
            return null;
        }
}
 
Example 6
Source File: CommentHelper.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public String getParameterName(DocTree dtree) {
    if (dtree.getKind() == PARAM) {
        return ((ParamTree) dtree).getName().toString();
    } else {
        return null;
    }
}
 
Example 7
Source File: Utils.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public boolean hasBlockTag(Element element, DocTree.Kind kind, final String tagName) {
    CommentHelper ch = getCommentHelper(element);
    String tname = tagName != null && tagName.startsWith("@")
            ? tagName.substring(1)
            : tagName;
    for (DocTree dt : getBlockTags(element, kind)) {
        if (dt.getKind() == kind) {
            if (tname == null || ch.getTagName(dt).equals(tname)) {
                return true;
            }
        }
    }
    return false;
}
 
Example 8
Source File: DocTreePath.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Creates a DocTreePath for a child node.
 * @param p the parent node
 * @param t the child node
 */
public DocTreePath(DocTreePath p, DocTree t) {
    if (t.getKind() == DocTree.Kind.DOC_COMMENT) {
        throw new IllegalArgumentException("Use DocTreePath(TreePath, DocCommentTree) to construct DocTreePath for a DocCommentTree.");
    } else {
        treePath = p.treePath;
        docComment = p.docComment;
        parent = p;
    }
    leaf = t;
}
 
Example 9
Source File: DocTreeMaker.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private boolean isSentenceBreak(DocTree dt, boolean isFirstDocTree) {
    switch (dt.getKind()) {
        case START_ELEMENT:
                StartElementTree set = (StartElementTree)dt;
                return !isFirstDocTree && ((DCTree) dt).pos > 1 && isSentenceBreak(set.getName());
        case END_ELEMENT:
                EndElementTree eet = (EndElementTree)dt;
                return !isFirstDocTree && ((DCTree) dt).pos > 1 && isSentenceBreak(eet.getName());
        default:
            return false;
    }
}
 
Example 10
Source File: Utils.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public List<? extends DocTree> filteredList(List<? extends DocTree> dlist, DocTree.Kind... select) {
    List<DocTree> list = new ArrayList<>(dlist.size());
    if (select == null)
        return dlist;
    for (DocTree dt : dlist) {
        if (dt.getKind() != ERRONEOUS) {
            for (DocTree.Kind kind : select) {
                if (dt.getKind() == kind) {
                    list.add(dt);
                }
            }
        }
    }
    return list;
}
 
Example 11
Source File: DocTreePath.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Creates a DocTreePath for a child node.
 */
public DocTreePath(DocTreePath p, DocTree t) {
    if (t.getKind() == DocTree.Kind.DOC_COMMENT) {
        throw new IllegalArgumentException("Use DocTreePath(TreePath, DocCommentTree) to construct DocTreePath for a DocCommentTree.");
    } else {
        treePath = p.treePath;
        docComment = p.docComment;
        parent = p;
    }
    leaf = t;
}
 
Example 12
Source File: Checker.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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 13
Source File: DocTreePath.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a DocTreePath for a child node.
 */
public DocTreePath(DocTreePath p, DocTree t) {
    if (t.getKind() == DocTree.Kind.DOC_COMMENT) {
        throw new IllegalArgumentException("Use DocTreePath(TreePath, DocCommentTree) to construct DocTreePath for a DocCommentTree.");
    } else {
        treePath = p.treePath;
        docComment = p.docComment;
        parent = p;
    }
    leaf = t;
}
 
Example 14
Source File: CommentHelper.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public ReferenceTree getType(DocTree dtree) {
    if (dtree.getKind() == SERIAL_FIELD) {
        return ((SerialFieldTree)dtree).getType();
    } else {
        return null;
    }
}
 
Example 15
Source File: DocTreePath.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a DocTreePath for a child node.
 */
public DocTreePath(DocTreePath p, DocTree t) {
    if (t.getKind() == DocTree.Kind.DOC_COMMENT) {
        throw new IllegalArgumentException("Use DocTreePath(TreePath, DocCommentTree) to construct DocTreePath for a DocCommentTree.");
    } else {
        treePath = p.treePath;
        docComment = p.docComment;
        parent = p;
    }
    leaf = t;
}
 
Example 16
Source File: Utils.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public boolean isOther(DocTree doctree) {
    return doctree.getKind() == DocTree.Kind.OTHER;
}
 
Example 17
Source File: JavaFixUtilities.java    From netbeans with Apache License 2.0 4 votes vote down vote up
static SpecificationVersion computeSpecVersion(CompilationInfo info, Element el) {
    if (!Utilities.isJavadocSupported(info)) return null;

    DocCommentTree javaDoc = info.getDocTrees().getDocCommentTree(el);

    if (javaDoc == null) return null;

    for (DocTree tag : javaDoc.getBlockTags()) {
        if (tag.getKind() != DocTree.Kind.SINCE) {
            continue;
        }

        String text = ((SinceTree) tag).getBody().toString();

        Matcher m = SPEC_VERSION.matcher(text);

        if (!m.find()) {
            continue;
        }

        return new SpecificationVersion(m.group()/*ver.toString()*/);
    }

    return null;
}
 
Example 18
Source File: ChangeParamsTransformer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static int compareTag(DocTree t, DocTree t1) {
    if(t.getKind() == t1.getKind()) {
        if(t.getKind() == DocTree.Kind.PARAM) {
            ParamTree p = (ParamTree) t;
            ParamTree p1 = (ParamTree) t1;
            if(p.isTypeParameter() && !p1.isTypeParameter()) {
                return HIGHER;
            } else if(!p.isTypeParameter() && p1.isTypeParameter()) {
                return LOWER;
            }
        }
        return EQUAL;
    }
    switch(t.getKind()) {
        case AUTHOR:
            return HIGHER;
        case VERSION:
            if(t1.getKind() == DocTree.Kind.AUTHOR) {
                return LOWER;
            }
            return HIGHER;
        case PARAM:
            if(t1.getKind() == DocTree.Kind.AUTHOR
                    || t1.getKind() == DocTree.Kind.VERSION) {
                return LOWER;
            }
            return HIGHER;
        case RETURN:
            if(t1.getKind() == DocTree.Kind.AUTHOR
                    || t1.getKind() == DocTree.Kind.VERSION
                    || t1.getKind() == DocTree.Kind.PARAM) {
                return LOWER;
            }
            return HIGHER;
        case EXCEPTION:
            if(t1.getKind() == DocTree.Kind.AUTHOR
                    || t1.getKind() == DocTree.Kind.VERSION
                    || t1.getKind() == DocTree.Kind.PARAM
                    || t1.getKind() == DocTree.Kind.RETURN) {
                return LOWER;
            }
            return HIGHER;
        case THROWS:
            if(t1.getKind() == DocTree.Kind.AUTHOR
                    || t1.getKind() == DocTree.Kind.VERSION
                    || t1.getKind() == DocTree.Kind.PARAM
                    || t1.getKind() == DocTree.Kind.RETURN
                    || t1.getKind() == DocTree.Kind.EXCEPTION) {
                return LOWER;
            }
            return HIGHER;
        case SEE:
            if(t1.getKind() == DocTree.Kind.AUTHOR
                    || t1.getKind() == DocTree.Kind.VERSION
                    || t1.getKind() == DocTree.Kind.PARAM
                    || t1.getKind() == DocTree.Kind.RETURN
                    || t1.getKind() == DocTree.Kind.EXCEPTION
                    || t1.getKind() == DocTree.Kind.THROWS) {
                return LOWER;
            }
            return HIGHER;
        case SINCE:
            if(t1.getKind() == DocTree.Kind.AUTHOR
                    || t1.getKind() == DocTree.Kind.VERSION
                    || t1.getKind() == DocTree.Kind.PARAM
                    || t1.getKind() == DocTree.Kind.RETURN
                    || t1.getKind() == DocTree.Kind.EXCEPTION
                    || t1.getKind() == DocTree.Kind.THROWS
                    || t1.getKind() == DocTree.Kind.SEE) {
                return LOWER;
            }
            return HIGHER;
        case SERIAL:
        case SERIAL_DATA:
        case SERIAL_FIELD:
            if(t1.getKind() == DocTree.Kind.AUTHOR
                    || t1.getKind() == DocTree.Kind.VERSION
                    || t1.getKind() == DocTree.Kind.PARAM
                    || t1.getKind() == DocTree.Kind.RETURN
                    || t1.getKind() == DocTree.Kind.EXCEPTION
                    || t1.getKind() == DocTree.Kind.THROWS
                    || t1.getKind() == DocTree.Kind.SEE
                    || t1.getKind() == DocTree.Kind.SINCE) {
                return LOWER;
            }
            return HIGHER;
        case DEPRECATED:
            if(t1.getKind() == DocTree.Kind.UNKNOWN_BLOCK_TAG) {
                return HIGHER;
            }
            return LOWER;
        case UNKNOWN_BLOCK_TAG:
            return LOWER;
    }
    return LOWER;
}
 
Example 19
Source File: CommentHelper.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public boolean isTypeParameter(DocTree dtree) {
    if (dtree.getKind() == PARAM) {
        return ((ParamTree)dtree).isTypeParameter();
    }
    return false;
}
 
Example 20
Source File: JavadocFormatter.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override public boolean matches(DocTree t) {
    return t.getKind() == DocTree.Kind.PARAM && ((ParamTree) t).isTypeParameter();
}