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


Java TokenTypes.METHOD_DEF属性代码示例

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


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

示例1: getAcceptableTokens

@Override
public int[] getAcceptableTokens() {
    return new int[] {
        TokenTypes.LITERAL_TRY,
        TokenTypes.LITERAL_CATCH,
        TokenTypes.LITERAL_FINALLY,
        TokenTypes.LITERAL_IF,
        TokenTypes.LITERAL_ELSE,
        TokenTypes.CLASS_DEF,
        TokenTypes.METHOD_DEF,
        TokenTypes.CTOR_DEF,
        TokenTypes.LITERAL_FOR,
        TokenTypes.LITERAL_WHILE,
        TokenTypes.LITERAL_DO,
        TokenTypes.STATIC_INIT,
        TokenTypes.INSTANCE_INIT,
        TokenTypes.LAMBDA,
    };
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:19,代码来源:RightCurlyCheck.java

示例2: leaveToken

@Override
public void leaveToken(DetailAST ast) {
    switch (ast.getType()) {
        case TokenTypes.CTOR_DEF:
        case TokenTypes.METHOD_DEF:
        case TokenTypes.INSTANCE_INIT:
        case TokenTypes.STATIC_INIT:
            leaveMemberDef(ast);
            break;
        case TokenTypes.SLIST:
            // Do nothing
            break;
        default:
            throw new IllegalStateException(ast.toString());
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:16,代码来源:ExecutableStatementCountCheck.java

示例3: visitSlist

/**
 * Process the end of a statement list.
 *
 * @param ast the token representing the statement list.
 */
private void visitSlist(DetailAST ast) {
    if (context.getAST() != null) {
        // find member AST for the statement list
        final DetailAST contextAST = context.getAST();
        DetailAST parent = ast.getParent();
        int type = parent.getType();
        while (type != TokenTypes.CTOR_DEF
            && type != TokenTypes.METHOD_DEF
            && type != TokenTypes.INSTANCE_INIT
            && type != TokenTypes.STATIC_INIT) {

            parent = parent.getParent();
            type = parent.getType();
        }
        if (parent == contextAST) {
            context.addCount(ast.getChildCount() / 2);
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:24,代码来源:ExecutableStatementCountCheck.java

示例4: isAnnotationOnType

/**
 * Checks whether annotation on type takes place.
 * @param modifier modifier token.
 * @return true if annotation on type takes place.
 */
private static boolean isAnnotationOnType(DetailAST modifier) {
    boolean annotationOnType = false;
    final DetailAST modifiers = modifier.getParent();
    final DetailAST definition = modifiers.getParent();
    final int definitionType = definition.getType();
    if (definitionType == TokenTypes.VARIABLE_DEF
            || definitionType == TokenTypes.PARAMETER_DEF
            || definitionType == TokenTypes.CTOR_DEF) {
        annotationOnType = true;
    }
    else if (definitionType == TokenTypes.METHOD_DEF) {
        final DetailAST typeToken = definition.findFirstToken(TokenTypes.TYPE);
        final int methodReturnType = typeToken.getLastChild().getType();
        if (methodReturnType != TokenTypes.LITERAL_VOID) {
            annotationOnType = true;
        }
    }
    return annotationOnType;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:24,代码来源:ModifierOrderCheck.java

示例5: testGetAcceptableTokens

@Test
public void testGetAcceptableTokens() {
    final CyclomaticComplexityCheck cyclomaticComplexityCheckObj =
        new CyclomaticComplexityCheck();
    final int[] actual = cyclomaticComplexityCheckObj.getAcceptableTokens();
    final int[] expected = {
        TokenTypes.CTOR_DEF,
        TokenTypes.METHOD_DEF,
        TokenTypes.INSTANCE_INIT,
        TokenTypes.STATIC_INIT,
        TokenTypes.LITERAL_WHILE,
        TokenTypes.LITERAL_DO,
        TokenTypes.LITERAL_FOR,
        TokenTypes.LITERAL_IF,
        TokenTypes.LITERAL_SWITCH,
        TokenTypes.LITERAL_CASE,
        TokenTypes.LITERAL_CATCH,
        TokenTypes.QUESTION,
        TokenTypes.LAND,
        TokenTypes.LOR,
    };
    Assert.assertArrayEquals("Invalid acceptable tokens", expected, actual);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:23,代码来源:CyclomaticComplexityCheckTest.java

示例6: 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,代码来源:AnnotationOnSameLineCheck.java

示例7: testGetRequiredTokens

@Test
public void testGetRequiredTokens() {
    final UnusedImportsCheck testCheckObject =
            new UnusedImportsCheck();
    final int[] actual = testCheckObject.getRequiredTokens();
    final int[] expected = {
        TokenTypes.IDENT,
        TokenTypes.IMPORT,
        TokenTypes.STATIC_IMPORT,
        // Definitions that may contain Javadoc...
        TokenTypes.PACKAGE_DEF,
        TokenTypes.ANNOTATION_DEF,
        TokenTypes.ANNOTATION_FIELD_DEF,
        TokenTypes.ENUM_DEF,
        TokenTypes.ENUM_CONSTANT_DEF,
        TokenTypes.CLASS_DEF,
        TokenTypes.INTERFACE_DEF,
        TokenTypes.METHOD_DEF,
        TokenTypes.CTOR_DEF,
        TokenTypes.VARIABLE_DEF,
    };

    assertArrayEquals("Default required tokens are invalid", expected, actual);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:24,代码来源:UnusedImportsCheckTest.java

示例8: visitToken

@Override
public void visitToken(DetailAST ast) {
    switch (ast.getType()) {
        case TokenTypes.METHOD_DEF:
            if (isVerifiable(ast)) {
                visitMethodDef(ast);
            }
            break;
        case TokenTypes.VARIABLE_DEF:
            if (isVerifiable(ast)) {
                visitVariableDef(ast);
            }
            break;
        case TokenTypes.PARAMETER_DEF:
            visitParameterDef(ast);
            break;
        case TokenTypes.IMPORT:
            visitImport(ast);
            break;
        default:
            throw new IllegalStateException(ast.toString());
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:23,代码来源:IllegalTypeCheck.java

示例9: hasBody

/**
 * Determines whether an AST is a method definition with a body, or is
 * a constructor definition.
 * @param aAST the AST to check.
 * @return if AST has a body.
 */
private boolean hasBody(DetailAST aAST)
{
    if (aAST.getType() == TokenTypes.METHOD_DEF) {
        return aAST.branchContains(TokenTypes.SLIST);
    }
    else if (aAST.getType() == TokenTypes.CTOR_DEF) {
        return true;
    }
    return false;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:16,代码来源:UnusedParameterCheck.java

示例10: isLocal

/**
 * Checks if a given method is local, i.e. either static or private.
 * @param aAST method def for check
 * @return true if a given method is iether static or private.
 */
private boolean isLocal(DetailAST aAST)
{
    if (aAST.getType() == TokenTypes.METHOD_DEF) {
        final DetailAST modifiers =
            aAST.findFirstToken(TokenTypes.MODIFIERS);
        return (modifiers == null)
            || modifiers.branchContains(TokenTypes.LITERAL_STATIC)
            || modifiers.branchContains(TokenTypes.LITERAL_PRIVATE);
    }
    return true;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:16,代码来源:UnusedParameterCheck.java

示例11: getDefaultTokens

/** @see com.puppycrawl.tools.checkstyle.api.Check */
public int[] getDefaultTokens()
{
    return new int[] {
        TokenTypes.METHOD_DEF,
    };
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:7,代码来源:UnusedPrivateMethodCheck.java

示例12: getRequiredTokens

@Override
public int[] getRequiredTokens() {
    return new int[] {
        TokenTypes.CLASS_DEF,
        TokenTypes.INTERFACE_DEF,
        TokenTypes.METHOD_DEF,
        TokenTypes.CTOR_DEF,
        TokenTypes.INSTANCE_INIT,
        TokenTypes.STATIC_INIT,
        TokenTypes.PACKAGE_DEF,
        TokenTypes.IMPORT,
        TokenTypes.VARIABLE_DEF,
        TokenTypes.CTOR_CALL,
        TokenTypes.SUPER_CTOR_CALL,
        TokenTypes.LITERAL_IF,
        TokenTypes.LITERAL_ELSE,
        TokenTypes.LITERAL_WHILE,
        TokenTypes.LITERAL_DO,
        TokenTypes.LITERAL_FOR,
        TokenTypes.LITERAL_SWITCH,
        TokenTypes.LITERAL_BREAK,
        TokenTypes.LITERAL_CONTINUE,
        TokenTypes.LITERAL_RETURN,
        TokenTypes.LITERAL_THROW,
        TokenTypes.LITERAL_SYNCHRONIZED,
        TokenTypes.LITERAL_CATCH,
        TokenTypes.LITERAL_FINALLY,
        TokenTypes.EXPR,
        TokenTypes.LABELED_STAT,
        TokenTypes.LITERAL_CASE,
        TokenTypes.LITERAL_DEFAULT,
    };
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:33,代码来源:JavaNCSSCheck.java

示例13: 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,
      };
}
 
开发者ID:startupheroes,项目名称:startupheroes-checkstyle,代码行数:11,代码来源:RedundantMultipleAnnotationCheck.java

示例14: getAcceptableTokens

@Override
public int[] getAcceptableTokens() {
    return new int[] {
        TokenTypes.METHOD_DEF,
        TokenTypes.VARIABLE_DEF,
        TokenTypes.ANNOTATION_FIELD_DEF,
        TokenTypes.INTERFACE_DEF,
        TokenTypes.CTOR_DEF,
        TokenTypes.CLASS_DEF,
        TokenTypes.ENUM_DEF,
        TokenTypes.RESOURCE,
    };
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:13,代码来源:RedundantModifierCheck.java

示例15: testGetAcceptableTokens

@Test
public void testGetAcceptableTokens() {
    final MethodLengthCheck methodLengthCheckObj =
        new MethodLengthCheck();
    final int[] actual = methodLengthCheckObj.getAcceptableTokens();
    final int[] expected = {
        TokenTypes.METHOD_DEF,
        TokenTypes.CTOR_DEF,
    };

    assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:12,代码来源:MethodLengthCheckTest.java


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