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


Java TokenTypes.TYPECAST属性代码示例

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


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

示例1: getAcceptableTokens

@Override
public int[] getAcceptableTokens() {
    return new int[] {
        TokenTypes.CLASS_DEF,
        TokenTypes.INTERFACE_DEF,
        TokenTypes.ENUM_DEF,
        TokenTypes.METHOD_DEF,
        TokenTypes.CTOR_DEF,
        TokenTypes.VARIABLE_DEF,
        TokenTypes.PARAMETER_DEF,
        TokenTypes.ANNOTATION_DEF,
        TokenTypes.TYPECAST,
        TokenTypes.LITERAL_THROWS,
        TokenTypes.IMPLEMENTS_CLAUSE,
        TokenTypes.TYPE_ARGUMENT,
        TokenTypes.LITERAL_NEW,
        TokenTypes.DOT,
        TokenTypes.ANNOTATION_FIELD_DEF,
    };
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:20,代码来源:AnnotationLocationCheck.java

示例2: visitToken

@Override
public void visitToken(DetailAST ast) {
    DetailAST nodeWithAnnotations = ast;
    if (ast.getType() == TokenTypes.TYPECAST) {
        nodeWithAnnotations = ast.findFirstToken(TokenTypes.TYPE);
    }
    DetailAST modifiersNode = nodeWithAnnotations.findFirstToken(TokenTypes.MODIFIERS);
    if (modifiersNode == null) {
        modifiersNode = nodeWithAnnotations.findFirstToken(TokenTypes.ANNOTATIONS);
    }
    if (modifiersNode != null) {
        for (DetailAST annotationNode = modifiersNode.getFirstChild();
                annotationNode != null;
                annotationNode = annotationNode.getNextSibling()) {
            if (annotationNode.getType() == TokenTypes.ANNOTATION
                    && annotationNode.getLineNo() != getNextNode(annotationNode).getLineNo()) {
                log(annotationNode.getLineNo(), MSG_KEY_ANNOTATION_ON_SAME_LINE,
                      getAnnotationName(annotationNode));
            }
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:22,代码来源:AnnotationOnSameLineCheck.java

示例3: getAcceptableTokens

@Override
public int[] getAcceptableTokens() {
    return new int[] {
        TokenTypes.ARRAY_INIT,
        TokenTypes.AT,
        TokenTypes.INC,
        TokenTypes.DEC,
        TokenTypes.UNARY_MINUS,
        TokenTypes.UNARY_PLUS,
        TokenTypes.BNOT,
        TokenTypes.LNOT,
        TokenTypes.DOT,
        TokenTypes.TYPECAST,
        TokenTypes.ARRAY_DECLARATOR,
        TokenTypes.INDEX_OP,
        TokenTypes.LITERAL_SYNCHRONIZED,
        TokenTypes.METHOD_REF,
    };
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:19,代码来源:NoWhitespaceAfterCheck.java

示例4: getWhitespaceFollowedNode

/**
 * For a visited ast node returns node that should be checked
 * for not being followed by whitespace.
 * @param ast
 *        , visited node.
 * @return node before ast.
 */
private static DetailAST getWhitespaceFollowedNode(DetailAST ast) {
    final DetailAST whitespaceFollowedAst;
    switch (ast.getType()) {
        case TokenTypes.TYPECAST:
            whitespaceFollowedAst = ast.findFirstToken(TokenTypes.RPAREN);
            break;
        case TokenTypes.ARRAY_DECLARATOR:
            whitespaceFollowedAst = getArrayDeclaratorPreviousElement(ast);
            break;
        case TokenTypes.INDEX_OP:
            whitespaceFollowedAst = getIndexOpPreviousElement(ast);
            break;
        default:
            whitespaceFollowedAst = ast;
    }
    return whitespaceFollowedAst;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:24,代码来源:NoWhitespaceAfterCheck.java

示例5: testGetAcceptableTokens

@Test
public void testGetAcceptableTokens() {
    final AnnotationLocationCheck constantNameCheckObj = new AnnotationLocationCheck();
    final int[] actual = constantNameCheckObj.getAcceptableTokens();
    final int[] expected = {
        TokenTypes.CLASS_DEF,
        TokenTypes.INTERFACE_DEF,
        TokenTypes.ENUM_DEF,
        TokenTypes.METHOD_DEF,
        TokenTypes.CTOR_DEF,
        TokenTypes.VARIABLE_DEF,
        TokenTypes.PARAMETER_DEF,
        TokenTypes.ANNOTATION_DEF,
        TokenTypes.TYPECAST,
        TokenTypes.LITERAL_THROWS,
        TokenTypes.IMPLEMENTS_CLAUSE,
        TokenTypes.TYPE_ARGUMENT,
        TokenTypes.LITERAL_NEW,
        TokenTypes.DOT,
        TokenTypes.ANNOTATION_FIELD_DEF,
        };
    assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:23,代码来源:AnnotationLocationCheckTest.java

示例6: testGetAcceptableTokens

@Test
public void testGetAcceptableTokens() {
    final AnnotationOnSameLineCheck constantNameCheckObj = new AnnotationOnSameLineCheck();
    final int[] actual = constantNameCheckObj.getAcceptableTokens();
    final int[] expected = {
        TokenTypes.CLASS_DEF,
        TokenTypes.INTERFACE_DEF,
        TokenTypes.ENUM_DEF,
        TokenTypes.METHOD_DEF,
        TokenTypes.CTOR_DEF,
        TokenTypes.VARIABLE_DEF,
        TokenTypes.PARAMETER_DEF,
        TokenTypes.ANNOTATION_DEF,
        TokenTypes.TYPECAST,
        TokenTypes.LITERAL_THROWS,
        TokenTypes.IMPLEMENTS_CLAUSE,
        TokenTypes.TYPE_ARGUMENT,
        TokenTypes.LITERAL_NEW,
        TokenTypes.DOT,
        TokenTypes.ANNOTATION_FIELD_DEF,
    };
    assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:23,代码来源:AnnotationOnSameLineCheckTest.java

示例7: getAcceptableTokens

@Override
public int[] getAcceptableTokens() {
  return new int[] {
      TokenTypes.CLASS_DEF,
      TokenTypes.INTERFACE_DEF,
      TokenTypes.ENUM_DEF,
      TokenTypes.METHOD_DEF,
      TokenTypes.CTOR_DEF,
      TokenTypes.VARIABLE_DEF,
      TokenTypes.PARAMETER_DEF,
      TokenTypes.ANNOTATION_DEF,
      TokenTypes.TYPECAST,
      TokenTypes.LITERAL_THROWS,
      TokenTypes.IMPLEMENTS_CLAUSE,
      TokenTypes.TYPE_ARGUMENT,
      TokenTypes.LITERAL_NEW,
      TokenTypes.DOT,
      TokenTypes.ANNOTATION_FIELD_DEF,
      };
}
 
开发者ID:startupheroes,项目名称:startupheroes-checkstyle,代码行数:20,代码来源:ForbiddenAnnotationCheck.java

示例8: visitToken

@Override
public void visitToken(DetailAST ast) {
    // Strange logic in this method to guard against checking RPAREN tokens
    // that are not associated with a TYPECAST token.
    if (ast.getType() == TokenTypes.TYPECAST) {
        processLeft(ast);
    }
    else if (ast.getParent().getType() == TokenTypes.TYPECAST
             && ast.getParent().findFirstToken(TokenTypes.RPAREN) == ast) {
        processRight(ast);
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:12,代码来源:TypecastParenPadCheck.java

示例9: getAcceptableTokens

@Override
public int[] getAcceptableTokens() {
    return new int[] {
        TokenTypes.COMMA,
        TokenTypes.SEMI,
        TokenTypes.TYPECAST,
        TokenTypes.LITERAL_IF,
        TokenTypes.LITERAL_ELSE,
        TokenTypes.LITERAL_WHILE,
        TokenTypes.LITERAL_DO,
        TokenTypes.LITERAL_FOR,
        TokenTypes.DO_WHILE,
    };
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:14,代码来源:WhitespaceAfterCheck.java

示例10: isInTypecast

/**
 * Checks whether {@link TokenTypes#RPAREN} is a closing paren
 * of a {@link TokenTypes#TYPECAST}.
 * @param ast of a {@link TokenTypes#RPAREN} to check.
 * @return true if ast is a closing paren of a {@link TokenTypes#TYPECAST}.
 */
private static boolean isInTypecast(DetailAST ast) {
    boolean result = false;
    if (ast.getParent().getType() == TokenTypes.TYPECAST) {
        final DetailAST firstRparen = ast.getParent().findFirstToken(TokenTypes.RPAREN);
        if (firstRparen.getLineNo() == ast.getLineNo()
                && firstRparen.getColumnNo() == ast.getColumnNo()) {
            result = true;
        }
    }
    return result;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:ParenPadCheck.java

示例11: testGetAcceptableTokens

@Test
public void testGetAcceptableTokens() {
    final TypecastParenPadCheck typecastParenPadCheckObj = new TypecastParenPadCheck();
    final int[] actual = typecastParenPadCheckObj.getAcceptableTokens();
    final int[] expected = {
        TokenTypes.RPAREN,
        TokenTypes.TYPECAST,
    };
    Assert.assertArrayEquals("Invalid acceptable tokens", expected, actual);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:10,代码来源:TypecastParenPadCheckTest.java

示例12: getRequiredTokens

@Override
public int[] getRequiredTokens() {
    return new int[] {TokenTypes.RPAREN, TokenTypes.TYPECAST};
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:4,代码来源:TypecastParenPadCheck.java


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