Java Code Examples for com.puppycrawl.tools.checkstyle.api.TokenTypes#VARIABLE_DEF

The following examples show how to use com.puppycrawl.tools.checkstyle.api.TokenTypes#VARIABLE_DEF . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PluralEnumNames.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
private boolean hasPublicStaticField(DetailAST ast) {
    DetailAST classBody = ast.findFirstToken(TokenTypes.OBJBLOCK);
    DetailAST maybeVariableDefinition = classBody.getFirstChild();

    String className = ast.findFirstToken(TokenTypes.IDENT).getText();

    // Filter out util classes
    if (className.endsWith("Utils")) {
        return false;
    }

    while (maybeVariableDefinition != null) {
        if (maybeVariableDefinition.getType() == TokenTypes.VARIABLE_DEF) {
            DetailAST modifiers = maybeVariableDefinition.findFirstToken(TokenTypes.MODIFIERS);
            if (modifiers != null && isPublic(modifiers) && isStatic(modifiers)) {
                return true;
            }
        }

        maybeVariableDefinition = maybeVariableDefinition.getNextSibling();
    }

    return false;
}
 
Example 2
Source File: MonitoringRecordFactoryConventionCheck.java    From kieker with Apache License 2.0 6 votes vote down vote up
/**
 * This method checks the fields of the record.
 *
 * @param ast
 *            The record class.
 */
private void checkFields(final DetailAST ast) {
	DetailAST child = ast.findFirstToken(TokenTypes.OBJBLOCK).findFirstToken(TokenTypes.VARIABLE_DEF);
	while (child != null) {
		if ((child.getType() == TokenTypes.VARIABLE_DEF)
				&& MonitoringRecordFactoryConventionCheck.isValidTypeField(child)) {
			// We found a valid field
			return;
		}

		child = child.getNextSibling();
	}

	// Seems like there is no valid field
	this.log(ast.getLineNo(), "invalid factory field");
}
 
Example 3
Source File: UnusedLocalVariableCheck.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** @see com.puppycrawl.tools.checkstyle.api.Check */
public int[] getDefaultTokens()
{
    return new int[] {
        TokenTypes.VARIABLE_DEF,
    };
}
 
Example 4
Source File: OneMethodPrivateFieldCheck.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** @see com.puppycrawl.tools.checkstyle.api.Check */
public int[] getDefaultTokens()
{
    return new int[] {
        TokenTypes.VARIABLE_DEF,
    };
}
 
Example 5
Source File: UnusedPrivateFieldCheck.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** @see com.puppycrawl.tools.checkstyle.api.Check */
public int[] getDefaultTokens()
{
    return new int[] {
        TokenTypes.VARIABLE_DEF,
    };
}
 
Example 6
Source File: UnusedLocalVariableCheck.java    From contribution with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** @see com.puppycrawl.tools.checkstyle.api.Check */
public int[] getDefaultTokens()
{
    return new int[] {
        TokenTypes.VARIABLE_DEF,
    };
}
 
Example 7
Source File: OneMethodPrivateFieldCheck.java    From contribution with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** @see com.puppycrawl.tools.checkstyle.api.Check */
public int[] getDefaultTokens()
{
    return new int[] {
        TokenTypes.VARIABLE_DEF,
    };
}
 
Example 8
Source File: UnusedPrivateFieldCheck.java    From contribution with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** @see com.puppycrawl.tools.checkstyle.api.Check */
public int[] getDefaultTokens()
{
    return new int[] {
        TokenTypes.VARIABLE_DEF,
    };
}
 
Example 9
Source File: NotAllowedSinceTagCheck.java    From kieker with Apache License 2.0 5 votes vote down vote up
@Override
public void visitToken(final DetailAST ast) {
	if (CSUtility.sinceTagAvailable(this, ast)
			&& ((ast.getType() == TokenTypes.VARIABLE_DEF) || !(CSUtility.parentIsInterface(ast)))) {
		this.log(ast.getLineNo(), "@since tag not allowed");
	}
}
 
Example 10
Source File: UnnecessaryFinalOnLocalVariableCheck.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@Override
public int[] getRequiredTokens() {
    return new int[] { TokenTypes.VARIABLE_DEF };
}
 
Example 11
Source File: NotAllowedSinceTagCheck.java    From kieker with Apache License 2.0 4 votes vote down vote up
@Override
public int[] getDefaultTokens() {
	// This here makes sure that we just get the correct components
	return new int[] { TokenTypes.METHOD_DEF, TokenTypes.VARIABLE_DEF };
}