本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.BLOCK_COMMENT_BEGIN属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.BLOCK_COMMENT_BEGIN属性的具体用法?Java TokenTypes.BLOCK_COMMENT_BEGIN怎么用?Java TokenTypes.BLOCK_COMMENT_BEGIN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.BLOCK_COMMENT_BEGIN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isOnPreviousLineIgnoringComments
/**
* Checks whether the checked statement is on the previous line ignoring empty lines
* and lines which contain only comments.
* @param currentStatement current statement.
* @param checkedStatement checked statement.
* @return true if checked statement is on the line which is previous to current statement
* ignoring empty lines and lines which contain only comments.
*/
private boolean isOnPreviousLineIgnoringComments(DetailAST currentStatement,
DetailAST checkedStatement) {
DetailAST nextToken = getNextToken(checkedStatement);
int distanceAim = 1;
if (nextToken != null && isComment(nextToken)) {
distanceAim += countEmptyLines(checkedStatement, currentStatement);
}
while (nextToken != null && nextToken != currentStatement && isComment(nextToken)) {
if (nextToken.getType() == TokenTypes.BLOCK_COMMENT_BEGIN) {
distanceAim += nextToken.getLastChild().getLineNo() - nextToken.getLineNo();
}
distanceAim++;
nextToken = nextToken.getNextSibling();
}
return currentStatement.getLineNo() - checkedStatement.getLineNo() == distanceAim;
}
示例2: isCorrectJavadocPosition
/**
* Checks Javadoc comment it's in right place.
* <p>From Javadoc util documentation:
* "Placement of comments - Documentation comments are recognized only when placed
* immediately before class, interface, constructor, method, field or annotation field
* declarations -- see the class example, method example, and field example.
* Documentation comments placed in the body of a method are ignored."</p>
* <p>If there are many documentation comments per declaration statement,
* only the last one will be recognized.</p>
*
* @param blockComment Block comment AST
* @return true if Javadoc is in right place
* @see <a href="https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javadoc.html">
* Javadoc util documentation</a>
*/
private static boolean isCorrectJavadocPosition(DetailAST blockComment) {
// We must be sure that after this one there are no other documentation comments.
DetailAST sibling = blockComment.getNextSibling();
while (sibling != null) {
if (sibling.getType() == TokenTypes.BLOCK_COMMENT_BEGIN) {
if (isJavadocComment(getBlockCommentContent(sibling))) {
// Found another javadoc comment, so this one should be ignored.
break;
}
sibling = sibling.getNextSibling();
}
else if (sibling.getType() == TokenTypes.SINGLE_LINE_COMMENT) {
sibling = sibling.getNextSibling();
}
else {
// Annotation, declaration or modifier is here. Do not check further.
sibling = null;
}
}
return sibling == null
&& (BlockCommentPosition.isOnType(blockComment)
|| BlockCommentPosition.isOnMember(blockComment));
}
示例3: getDefaultTokens
@Override
public int[] getDefaultTokens() {
return new int[] {
TokenTypes.SINGLE_LINE_COMMENT,
TokenTypes.BLOCK_COMMENT_BEGIN,
};
}
示例4: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.SINGLE_LINE_COMMENT,
TokenTypes.BLOCK_COMMENT_BEGIN,
};
}
示例5: visitToken
@Override
public void visitToken(DetailAST commentAst) {
switch (commentAst.getType()) {
case TokenTypes.SINGLE_LINE_COMMENT:
case TokenTypes.BLOCK_COMMENT_BEGIN:
visitComment(commentAst);
break;
default:
final String exceptionMsg = "Unexpected token type: " + commentAst.getText();
throw new IllegalArgumentException(exceptionMsg);
}
}
示例6: isComment
/**
* Whether the ast is a comment.
* @param ast the ast to check.
* @return true if the ast is a comment.
*/
private static boolean isComment(DetailAST ast) {
final int astType = ast.getType();
return astType == TokenTypes.SINGLE_LINE_COMMENT
|| astType == TokenTypes.BLOCK_COMMENT_BEGIN
|| astType == TokenTypes.COMMENT_CONTENT
|| astType == TokenTypes.BLOCK_COMMENT_END;
}
示例7: testGetRequiredTokens
@Test
public void testGetRequiredTokens() {
final NonEmptyAtclauseDescriptionCheck checkObj =
new NonEmptyAtclauseDescriptionCheck();
final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN};
assertArrayEquals("Default required tokens are invalid",
expected, checkObj.getRequiredTokens());
}
示例8: testGetAcceptableTokens
@Test
public void testGetAcceptableTokens() {
final NonEmptyAtclauseDescriptionCheck checkObj =
new NonEmptyAtclauseDescriptionCheck();
final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN};
assertArrayEquals("Default acceptable tokens are invalid",
expected, checkObj.getAcceptableTokens());
}
示例9: isPrecededByJavadoc
/**
* Check if token is preceded by javadoc comment.
* @param token token for check.
* @return true, if token is preceded by javadoc comment.
*/
private static boolean isPrecededByJavadoc(DetailAST token) {
boolean result = false;
final DetailAST previous = token.getPreviousSibling();
if (previous.getType() == TokenTypes.BLOCK_COMMENT_BEGIN
&& JavadocUtils.isJavadocComment(previous.getFirstChild().getText())) {
result = true;
}
return result;
}
示例10: getNextSiblingSkipComments
/**
* Get next sibling node skipping any comment nodes.
* @param node current node
* @return next sibling
*/
private static DetailAST getNextSiblingSkipComments(DetailAST node) {
DetailAST result = node.getNextSibling();
while (result.getType() == TokenTypes.SINGLE_LINE_COMMENT
|| result.getType() == TokenTypes.BLOCK_COMMENT_BEGIN) {
result = result.getNextSibling();
}
return result;
}
示例11: getPrevSiblingSkipComments
/**
* Get previous sibling node skipping any comments.
* @param node current node
* @return previous sibling
*/
private static DetailAST getPrevSiblingSkipComments(DetailAST node) {
DetailAST result = node.getPreviousSibling();
while (result != null
&& (result.getType() == TokenTypes.SINGLE_LINE_COMMENT
|| result.getType() == TokenTypes.BLOCK_COMMENT_BEGIN)) {
result = result.getPreviousSibling();
}
return result;
}
示例12: testGetRequiredTokens
@Test
public void testGetRequiredTokens() {
final JavadocTagContinuationIndentationCheck checkObj =
new JavadocTagContinuationIndentationCheck();
final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN };
assertArrayEquals("Default required tokens are invalid",
expected, checkObj.getRequiredTokens());
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:8,代码来源:JavadocTagContinuationIndentationCheckTest.java
示例13: testAcceptableTokens
@Test
public void testAcceptableTokens() {
final SingleLineJavadocCheck checkObj = new SingleLineJavadocCheck();
final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN };
assertArrayEquals("Default acceptable tokens are invalid",
expected, checkObj.getAcceptableTokens());
}
示例14: testGetRequiredTokens
@Test
public void testGetRequiredTokens() {
final SingleLineJavadocCheck checkObj = new SingleLineJavadocCheck();
final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN };
assertArrayEquals("Default required tokens are invalid",
expected, checkObj.getRequiredTokens());
}
示例15: testGetAcceptableTokens
@Test
public void testGetAcceptableTokens() {
final AtclauseOrderCheck checkObj = new AtclauseOrderCheck();
final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN};
assertArrayEquals("Default acceptable tokens are invalid",
expected, checkObj.getAcceptableTokens());
}