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


Java JavadocTokenTypes类代码示例

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


JavadocTokenTypes类属于com.puppycrawl.tools.checkstyle.api包,在下文中一共展示了JavadocTokenTypes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startsWithInheritDoc

import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; //导入依赖的package包/类
/**
 * Checks if the node starts with an {@inheritDoc}.
 * @param root The root node to examine.
 * @return {@code true} if the javadoc starts with an {@inheritDoc}.
 */
private static boolean startsWithInheritDoc(DetailNode root) {
    boolean found = false;
    final DetailNode[] children = root.getChildren();

    for (int i = 0; !found && i < children.length - 1; i++) {
        final DetailNode child = children[i];
        if (child.getType() == JavadocTokenTypes.JAVADOC_INLINE_TAG
                && child.getChildren()[1].getType() == JavadocTokenTypes.INHERIT_DOC_LITERAL) {
            found = true;
        }
        else if (child.getType() != JavadocTokenTypes.LEADING_ASTERISK
                && !CommonUtils.isBlank(child.getText())) {
            break;
        }
    }

    return found;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:24,代码来源:SummaryJavadocCheck.java

示例2: getSummarySentence

import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; //导入依赖的package包/类
/**
 * Checks if period is at the end of sentence.
 * @param ast Javadoc root node.
 * @return error string
 */
private static String getSummarySentence(DetailNode ast) {
    boolean flag = true;
    final StringBuilder result = new StringBuilder(256);
    for (DetailNode child : ast.getChildren()) {
        if (ALLOWED_TYPES.contains(child.getType())) {
            result.append(child.getText());
        }
        else if (child.getType() == JavadocTokenTypes.HTML_ELEMENT
                && CommonUtils.isBlank(result.toString().trim())) {
            result.append(getStringInsideTag(result.toString(),
                    child.getChildren()[0].getChildren()[0]));
        }
        else if (child.getType() == JavadocTokenTypes.JAVADOC_TAG) {
            flag = false;
        }
        if (!flag) {
            break;
        }
    }
    return result.toString().trim();
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:27,代码来源:SummaryJavadocCheck.java

示例3: getFirstSentence

import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; //导入依赖的package包/类
/**
 * Finds and returns first sentence.
 * @param ast Javadoc root node.
 * @return first sentence.
 */
private static String getFirstSentence(DetailNode ast) {
    final StringBuilder result = new StringBuilder(256);
    final String periodSuffix = PERIOD + ' ';
    for (DetailNode child : ast.getChildren()) {
        final String text;
        if (child.getChildren().length == 0) {
            text = child.getText();
        }
        else {
            text = getFirstSentence(child);
        }

        if (child.getType() != JavadocTokenTypes.JAVADOC_INLINE_TAG
            && text.contains(periodSuffix)) {
            result.append(text.substring(0, text.indexOf(periodSuffix) + 1));
            break;
        }
        else {
            result.append(text);
        }
    }
    return result.toString();
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:29,代码来源:SummaryJavadocCheck.java

示例4: checkOrderInTagSection

import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; //导入依赖的package包/类
/**
 * Checks order of atclauses in tag section node.
 * @param javadoc Javadoc root node.
 */
private void checkOrderInTagSection(DetailNode javadoc) {
    int maxIndexOfPreviousTag = 0;

    for (DetailNode node : javadoc.getChildren()) {
        if (node.getType() == JavadocTokenTypes.JAVADOC_TAG) {
            final String tagText = JavadocUtils.getFirstChild(node).getText();
            final int indexOfCurrentTag = tagOrder.indexOf(tagText);

            if (indexOfCurrentTag != -1) {
                if (indexOfCurrentTag < maxIndexOfPreviousTag) {
                    log(node.getLineNumber(), MSG_KEY, tagOrder.toString());
                }
                else {
                    maxIndexOfPreviousTag = indexOfCurrentTag;
                }
            }
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:24,代码来源:AtclauseOrderCheck.java

示例5: isFirstParagraph

import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; //导入依赖的package包/类
/**
 * Determines whether or not the line with paragraph tag is first line in javadoc.
 * @param paragraphTag paragraph tag.
 * @return true, if line with paragraph tag is first line in javadoc.
 */
private static boolean isFirstParagraph(DetailNode paragraphTag) {
    boolean result = true;
    DetailNode previousNode = JavadocUtils.getPreviousSibling(paragraphTag);
    while (previousNode != null) {
        if (previousNode.getType() == JavadocTokenTypes.TEXT
                && !CommonUtils.isBlank(previousNode.getText())
            || previousNode.getType() != JavadocTokenTypes.LEADING_ASTERISK
                && previousNode.getType() != JavadocTokenTypes.NEWLINE
                && previousNode.getType() != JavadocTokenTypes.TEXT) {
            result = false;
            break;
        }
        previousNode = JavadocUtils.getPreviousSibling(previousNode);
    }
    return result;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:22,代码来源:JavadocParagraphCheck.java

示例6: visitJavadocToken

import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; //导入依赖的package包/类
@Override
public void visitJavadocToken(DetailNode ast) {
    if (!isInlineDescription(ast)) {
        final List<DetailNode> textNodes = getAllNewlineNodes(ast);
        for (DetailNode newlineNode : textNodes) {
            final DetailNode textNode = JavadocUtils.getNextSibling(JavadocUtils
                    .getNextSibling(newlineNode));
            if (textNode != null && textNode.getType() == JavadocTokenTypes.TEXT) {
                final String text = textNode.getText();
                if (!CommonUtils.isBlank(text.trim())
                        && (text.length() <= offset
                                || !text.substring(1, offset + 1).trim().isEmpty())) {
                    log(textNode.getLineNumber(), MSG_KEY, offset);
                }
            }
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:19,代码来源:JavadocTagContinuationIndentationCheck.java

示例7: printTree

import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; //导入依赖的package包/类
/**
 * Print AST.
 * @param ast the root AST node.
 * @param rootPrefix prefix for the root node
 * @param prefix prefix for other nodes
 * @return string AST.
 */
public static String printTree(DetailNode ast, String rootPrefix, String prefix) {
    final StringBuilder messageBuilder = new StringBuilder(1024);
    DetailNode node = ast;
    while (node != null) {
        if (node.getType() == JavadocTokenTypes.JAVADOC) {
            messageBuilder.append(rootPrefix);
        }
        else {
            messageBuilder.append(prefix);
        }
        messageBuilder.append(getIndentation(node))
                .append(JavadocUtils.getTokenName(node.getType())).append(" -> ")
                .append(JavadocUtils.escapeAllControlChars(node.getText())).append(" [")
                .append(node.getLineNumber()).append(':').append(node.getColumnNumber())
                .append(']').append(LINE_SEPARATOR)
                .append(printTree(JavadocUtils.getFirstChild(node), rootPrefix, prefix));
        node = JavadocUtils.getNextSibling(node);
    }
    return messageBuilder.toString();
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:28,代码来源:DetailNodeTreeStringPrinter.java

示例8: getTokenName

import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; //导入依赖的package包/类
/**
 * Returns the name of a token for a given ID.
 * @param id
 *        the ID of the token name to get
 * @return a token name
 */
public static String getTokenName(int id) {
    final String name;
    if (id == JavadocTokenTypes.EOF) {
        name = "EOF";
    }
    else if (id > TOKEN_VALUE_TO_NAME.length - 1) {
        throw new IllegalArgumentException(UNKNOWN_JAVADOC_TOKEN_ID_EXCEPTION_MESSAGE + id);
    }
    else {
        name = TOKEN_VALUE_TO_NAME[id];
        if (name == null) {
            throw new IllegalArgumentException(UNKNOWN_JAVADOC_TOKEN_ID_EXCEPTION_MESSAGE + id);
        }
    }
    return name;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:23,代码来源:JavadocUtils.java

示例9: testBranchContains

import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; //导入依赖的package包/类
@Test
public void testBranchContains() {
    final JavadocNodeImpl node = new JavadocNodeImpl();
    final JavadocNodeImpl firstChild = new JavadocNodeImpl();
    final JavadocNodeImpl secondChild = new JavadocNodeImpl();

    node.setType(JavadocTokenTypes.JAVADOC);
    firstChild.setType(JavadocTokenTypes.BODY_TAG_START);
    secondChild.setType(JavadocTokenTypes.CODE_LITERAL);

    node.setChildren(firstChild, secondChild);
    assertFalse("Should return true when branch contains node passed",
            JavadocUtils.containsInBranch(node, JavadocTokenTypes.AUTHOR_LITERAL));

    firstChild.setParent(node);
    secondChild.setParent(node);
    assertFalse("Should return false when branch does not contain node passed",
            JavadocUtils.containsInBranch(node, JavadocTokenTypes.AUTHOR_LITERAL));

    secondChild.setType(JavadocTokenTypes.AUTHOR_LITERAL);
    assertTrue("Should return true when branch contains node passed",
            JavadocUtils.containsInBranch(node, JavadocTokenTypes.AUTHOR_LITERAL));
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:24,代码来源:JavadocUtilsTest.java

示例10: testGetFirstToken

import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; //导入依赖的package包/类
@Test
public void testGetFirstToken() {
    final JavadocNodeImpl javadocNode = new JavadocNodeImpl();
    final JavadocNodeImpl basetag = new JavadocNodeImpl();
    basetag.setType(JavadocTokenTypes.BASE_TAG);
    final JavadocNodeImpl body = new JavadocNodeImpl();
    body.setType(JavadocTokenTypes.BODY);

    body.setParent(javadocNode);
    basetag.setParent(javadocNode);
    javadocNode.setChildren(basetag, body);

    final DetailNode result = JavadocUtils.findFirstToken(javadocNode, JavadocTokenTypes.BODY);

    assertEquals("Invalid first token", body, result);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:JavadocUtilsTest.java

示例11: printTree

import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; //导入依赖的package包/类
public static void printTree(DetailNode aRoot)
{

    if (aRoot.getChildren().length != 0) {
        for (DetailNode node : aRoot.getChildren()) {
            System.out.println(getLevel(node) + node.toString()
                    + " : ["
                    + node.getText().replaceAll("\n", "\\\\n").replaceAll("\r", "\\\\r")
                    .replaceAll("\t", "\\\\t")
                    + "]");

            if (node.getType() == JavadocTokenTypes.TEXT) {
                continue;
            }

            printTree(node);
        }
    }
}
 
开发者ID:checkstyle,项目名称:contribution,代码行数:20,代码来源:JavadocTreePrinter.java

示例12: getStringInsideTag

import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; //导入依赖的package包/类
/**
 * Concatenates string within text of html tags.
 * @param result javadoc string
 * @param detailNode javadoc tag node
 * @return java doc tag content appended in result
 */
private static String getStringInsideTag(String result, DetailNode detailNode) {
    final StringBuilder contents = new StringBuilder(result);
    DetailNode tempNode = detailNode;
    while (tempNode != null) {
        if (tempNode.getType() == JavadocTokenTypes.TEXT) {
            contents.append(tempNode.getText());
        }
        tempNode = JavadocUtils.getNextSibling(tempNode);
    }
    return contents.toString();
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:18,代码来源:SummaryJavadocCheck.java

示例13: hasJavadocInlineTags

import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; //导入依赖的package包/类
/**
 * Checks if comment has in-line tags which are not ignored.
 *
 * @param javadocRoot javadoc root node.
 * @return true, if comment has in-line tags which are not ignored.
 * @see <a href=
 * https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#javadoctags>
 * JavadocTags</a>
 */
private boolean hasJavadocInlineTags(DetailNode javadocRoot) {
    DetailNode javadocTagSection =
            JavadocUtils.findFirstToken(javadocRoot, JavadocTokenTypes.JAVADOC_INLINE_TAG);
    boolean foundTag = false;
    while (javadocTagSection != null) {
        if (!isTagIgnored(javadocTagSection)) {
            foundTag = true;
            break;
        }
        javadocTagSection = JavadocUtils.getNextSibling(
                javadocTagSection, JavadocTokenTypes.JAVADOC_INLINE_TAG);
    }
    return foundTag;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:24,代码来源:SingleLineJavadocCheck.java

示例14: getDefaultJavadocTokens

import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; //导入依赖的package包/类
@Override
public int[] getDefaultJavadocTokens() {
    return new int[] {
        JavadocTokenTypes.PARAM_LITERAL,
        JavadocTokenTypes.RETURN_LITERAL,
        JavadocTokenTypes.THROWS_LITERAL,
        JavadocTokenTypes.EXCEPTION_LITERAL,
        JavadocTokenTypes.DEPRECATED_LITERAL,
    };
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:11,代码来源:NonEmptyAtclauseDescriptionCheck.java

示例15: getDefaultJavadocTokens

import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; //导入依赖的package包/类
@Override
public int[] getDefaultJavadocTokens() {
    return new int[] {
        JavadocTokenTypes.NEWLINE,
        JavadocTokenTypes.HTML_ELEMENT,
    };
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:8,代码来源:JavadocParagraphCheck.java


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