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


Java TokenTypes.TYPE_ARGUMENT属性代码示例

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


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

示例3: 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

示例4: 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

示例5: getAcceptableParent

/**
 * Returns parent of given ast if parent has one of the following types:
 * ANNOTATION_DEF, PACKAGE_DEF, CLASS_DEF, ENUM_DEF, ENUM_CONSTANT_DEF, CTOR_DEF,
 * METHOD_DEF, PARAMETER_DEF, VARIABLE_DEF, ANNOTATION_FIELD_DEF, TYPE, LITERAL_NEW,
 * LITERAL_THROWS, TYPE_ARGUMENT, IMPLEMENTS_CLAUSE, DOT.
 * @param child an ast
 * @return returns ast - parent of given
 */
private static DetailAST getAcceptableParent(DetailAST child) {
    final DetailAST result;
    final DetailAST parent = child.getParent();
    switch (parent.getType()) {
        case TokenTypes.ANNOTATION_DEF:
        case TokenTypes.PACKAGE_DEF:
        case TokenTypes.CLASS_DEF:
        case TokenTypes.INTERFACE_DEF:
        case TokenTypes.ENUM_DEF:
        case TokenTypes.ENUM_CONSTANT_DEF:
        case TokenTypes.CTOR_DEF:
        case TokenTypes.METHOD_DEF:
        case TokenTypes.PARAMETER_DEF:
        case TokenTypes.VARIABLE_DEF:
        case TokenTypes.ANNOTATION_FIELD_DEF:
        case TokenTypes.TYPE:
        case TokenTypes.LITERAL_NEW:
        case TokenTypes.LITERAL_THROWS:
        case TokenTypes.TYPE_ARGUMENT:
        case TokenTypes.IMPLEMENTS_CLAUSE:
        case TokenTypes.DOT:
            result = parent;
            break;
        default:
            // it's possible case, but shouldn't be processed here
            result = null;
    }
    return result;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:37,代码来源:SuppressWarningsHolder.java

示例6: getArrayDeclaratorPreviousElement

/**
 * Returns proper argument for getPositionAfter method, it is a token after
 * {@link TokenTypes#ARRAY_DECLARATOR ARRAY_DECLARATOR}, in can be {@link TokenTypes#RBRACK
 * RBRACK}, {@link TokenTypes#IDENT IDENT} or an array type definition (literal).
 * @param ast
 *        , {@link TokenTypes#ARRAY_DECLARATOR ARRAY_DECLARATOR} node.
 * @return previous node by text order.
 */
private static DetailAST getArrayDeclaratorPreviousElement(DetailAST ast) {
    final DetailAST previousElement;
    final DetailAST firstChild = ast.getFirstChild();
    if (firstChild.getType() == TokenTypes.ARRAY_DECLARATOR) {
        // second or higher array index
        previousElement = firstChild.findFirstToken(TokenTypes.RBRACK);
    }
    else {
        // first array index, is preceded with identifier or type
        final DetailAST parent = getFirstNonArrayDeclaratorParent(ast);
        switch (parent.getType()) {
            // generics
            case TokenTypes.TYPE_ARGUMENT:
                final DetailAST wildcard = parent.findFirstToken(TokenTypes.WILDCARD_TYPE);
                if (wildcard == null) {
                    // usual generic type argument like <char[]>
                    previousElement = getTypeLastNode(ast);
                }
                else {
                    // constructions with wildcard like <? extends String[]>
                    previousElement = getTypeLastNode(ast.getFirstChild());
                }
                break;
            // 'new' is a special case with its own subtree structure
            case TokenTypes.LITERAL_NEW:
                previousElement = getTypeLastNode(parent);
                break;
            // mundane array declaration, can be either java style or C style
            case TokenTypes.TYPE:
                previousElement = getPreviousNodeWithParentOfTypeAst(ast, parent);
                break;
            // i.e. boolean[].class
            case TokenTypes.DOT:
                previousElement = getTypeLastNode(ast);
                break;
            // java 8 method reference
            case TokenTypes.METHOD_REF:
                final DetailAST ident = getIdentLastToken(ast);
                if (ident == null) {
                    //i.e. int[]::new
                    previousElement = ast.getFirstChild();
                }
                else {
                    previousElement = ident;
                }
                break;
            default:
                throw new IllegalStateException("unexpected ast syntax " + parent);
        }
    }
    return previousElement;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:60,代码来源:NoWhitespaceAfterCheck.java


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