Prefixes, whitespace, #512

This commit is contained in:
alexkravin 2015-01-11 14:10:07 +04:00
parent 5cfe30d7ad
commit d97a2df674
21 changed files with 318 additions and 318 deletions

View File

@ -43,47 +43,47 @@ abstract class AbstractParenPadCheck
/**
* Process a token representing a left parentheses.
* @param aAST the token representing a left parentheses
* @param ast the token representing a left parentheses
*/
protected void processLeft(DetailAST aAST)
protected void processLeft(DetailAST ast)
{
final String line = getLines()[aAST.getLineNo() - 1];
final int after = aAST.getColumnNo() + 1;
final String line = getLines()[ast.getLineNo() - 1];
final int after = ast.getColumnNo() + 1;
if (after < line.length()) {
if ((PadOption.NOSPACE == getAbstractOption())
&& (Character.isWhitespace(line.charAt(after))))
{
log(aAST.getLineNo(), after, "ws.followed", "(");
log(ast.getLineNo(), after, "ws.followed", "(");
}
else if ((PadOption.SPACE == getAbstractOption())
&& !Character.isWhitespace(line.charAt(after))
&& (line.charAt(after) != ')'))
{
log(aAST.getLineNo(), after, "ws.notFollowed", "(");
log(ast.getLineNo(), after, "ws.notFollowed", "(");
}
}
}
/**
* Process a token representing a right parentheses.
* @param aAST the token representing a right parentheses
* @param ast the token representing a right parentheses
*/
protected void processRight(DetailAST aAST)
protected void processRight(DetailAST ast)
{
final String line = getLines()[aAST.getLineNo() - 1];
final int before = aAST.getColumnNo() - 1;
final String line = getLines()[ast.getLineNo() - 1];
final int before = ast.getColumnNo() - 1;
if (before >= 0) {
if ((PadOption.NOSPACE == getAbstractOption())
&& Character.isWhitespace(line.charAt(before))
&& !Utils.whitespaceBefore(before, line))
{
log(aAST.getLineNo(), before, "ws.preceded", ")");
log(ast.getLineNo(), before, "ws.preceded", ")");
}
else if ((PadOption.SPACE == getAbstractOption())
&& !Character.isWhitespace(line.charAt(before))
&& (line.charAt(before) != '('))
{
log(aAST.getLineNo(), aAST.getColumnNo(),
log(ast.getLineNo(), ast.getColumnNo(),
"ws.notPreceded", ")");
}
}

View File

@ -66,11 +66,11 @@ public class EmptyForInitializerPadCheck
}
@Override
public void visitToken(DetailAST aAST)
public void visitToken(DetailAST ast)
{
if (aAST.getChildCount() == 0) {
if (ast.getChildCount() == 0) {
//empty for initializer. test pad before semi.
final DetailAST semi = aAST.getNextSibling();
final DetailAST semi = ast.getNextSibling();
final int semiLineIdx = semi.getLineNo() - 1;
final String line = getLines()[semiLineIdx];
final int before = semi.getColumnNo() - 1;

View File

@ -66,11 +66,11 @@ public class EmptyForIteratorPadCheck
}
@Override
public void visitToken(DetailAST aAST)
public void visitToken(DetailAST ast)
{
if (aAST.getChildCount() == 0) {
if (ast.getChildCount() == 0) {
//empty for iterator. test pad after semi.
final DetailAST semi = aAST.getPreviousSibling();
final DetailAST semi = ast.getPreviousSibling();
final String line = getLines()[semi.getLineNo() - 1];
final int after = semi.getColumnNo() + 1;
//don't check if at end of line

View File

@ -112,16 +112,16 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes;
public class EmptyLineSeparatorCheck extends Check
{
/** */
private boolean mAllowNoEmptyLineBetweenFields;
private boolean allowNoEmptyLineBetweenFields;
/**
* Allow no empty line between fields.
* @param aAllow
* @param allow
* User's value.
*/
public final void setAllowNoEmptyLineBetweenFields(boolean aAllow)
public final void setAllowNoEmptyLineBetweenFields(boolean allow)
{
mAllowNoEmptyLineBetweenFields = aAllow;
allowNoEmptyLineBetweenFields = allow;
}
@Override
@ -142,39 +142,39 @@ public class EmptyLineSeparatorCheck extends Check
}
@Override
public void visitToken(DetailAST aAST)
public void visitToken(DetailAST ast)
{
final DetailAST nextToken = aAST.getNextSibling();
final DetailAST nextToken = ast.getNextSibling();
if (nextToken != null && nextToken.getType() != TokenTypes.RCURLY) {
final int astType = aAST.getType();
final int astType = ast.getType();
switch (astType) {
case TokenTypes.VARIABLE_DEF:
if (isTypeField(aAST) && !hasEmptyLineAfter(aAST)) {
if (mAllowNoEmptyLineBetweenFields
if (iastypeField(ast) && !hasEmptyLineAfter(ast)) {
if (allowNoEmptyLineBetweenFields
&& nextToken.getType() != TokenTypes.VARIABLE_DEF)
{
log(nextToken.getLineNo(), "empty.line.separator", nextToken.getText());
}
else if (!mAllowNoEmptyLineBetweenFields) {
else if (!allowNoEmptyLineBetweenFields) {
log(nextToken.getLineNo(), "empty.line.separator", nextToken.getText());
}
}
break;
case TokenTypes.IMPORT:
if (astType != nextToken.getType() && !hasEmptyLineAfter(aAST)
|| (aAST.getLineNo() > 1 && !hasEmptyLineBefore(aAST)
&& aAST.getPreviousSibling() == null))
if (astType != nextToken.getType() && !hasEmptyLineAfter(ast)
|| (ast.getLineNo() > 1 && !hasEmptyLineBefore(ast)
&& ast.getPreviousSibling() == null))
{
log(nextToken.getLineNo(), "empty.line.separator", nextToken.getText());
}
break;
case TokenTypes.PACKAGE_DEF:
if (aAST.getLineNo() > 1 && !hasEmptyLineBefore(aAST)) {
log(aAST.getLineNo(), "empty.line.separator", aAST.getText());
if (ast.getLineNo() > 1 && !hasEmptyLineBefore(ast)) {
log(ast.getLineNo(), "empty.line.separator", ast.getText());
}
default:
if (!hasEmptyLineAfter(aAST)) {
if (!hasEmptyLineAfter(ast)) {
log(nextToken.getLineNo(), "empty.line.separator", nextToken.getText());
}
}
@ -183,26 +183,26 @@ public class EmptyLineSeparatorCheck extends Check
/**
* Checks if token have empty line after.
* @param aToken token.
* @param token token.
* @return true if token have empty line after.
*/
private boolean hasEmptyLineAfter(DetailAST aToken)
private boolean hasEmptyLineAfter(DetailAST token)
{
DetailAST lastToken = aToken.getLastChild().getLastChild();
DetailAST lastToken = token.getLastChild().getLastChild();
if (null == lastToken) {
lastToken = aToken.getLastChild();
lastToken = token.getLastChild();
}
return aToken.getNextSibling().getLineNo() - lastToken.getLineNo() > 1;
return token.getNextSibling().getLineNo() - lastToken.getLineNo() > 1;
}
/**
* Checks if a token has a empty line before.
* @param aToken token.
* @param token token.
* @return true, if token have empty line before.
*/
private boolean hasEmptyLineBefore(DetailAST aToken)
private boolean hasEmptyLineBefore(DetailAST token)
{
final int lineNo = aToken.getLineNo();
final int lineNo = token.getLineNo();
// [lineNo - 2] is the number of the previous line because the numbering starts from zero.
final String lineBefore = getLines()[lineNo - 2];
return lineBefore.trim().isEmpty();
@ -210,12 +210,12 @@ public class EmptyLineSeparatorCheck extends Check
/**
* If variable definition is a type field.
* @param aVariableDef variable definition.
* @param variableDef variable definition.
* @return true variable definition is a type field.
*/
private boolean isTypeField(DetailAST aVariableDef)
private boolean iastypeField(DetailAST variableDef)
{
final int parentType = aVariableDef.getParent().getParent().getType();
final int parentType = variableDef.getParent().getParent().getType();
return parentType == TokenTypes.CLASS_DEF;
}
}

View File

@ -29,17 +29,17 @@ import java.util.List;
public class FileTabCharacterCheck extends AbstractFileSetCheck
{
/** Indicates whether to report once per file, or for each line. */
private boolean mEachLine;
private boolean eachLine;
@Override
protected void processFiltered(File aFile, List<String> aLines)
protected void processFiltered(File file, List<String> lines)
{
int lineNum = 0;
for (final String line : aLines) {
for (final String line : lines) {
lineNum++;
final int tabPosition = line.indexOf('\t');
if (tabPosition != -1) {
if (mEachLine) {
if (eachLine) {
log(lineNum, tabPosition + 1, "containsTab");
}
else {
@ -52,10 +52,10 @@ public class FileTabCharacterCheck extends AbstractFileSetCheck
/**
* Whether report on each line containing a tab.
* @param aEachLine Whether report on each line containing a tab.
* @param eachLine Whether report on each line containing a tab.
*/
public void setEachLine(boolean aEachLine)
public void setEachLine(boolean eachLine)
{
mEachLine = aEachLine;
this.eachLine = eachLine;
}
}

View File

@ -67,7 +67,7 @@ import com.puppycrawl.tools.checkstyle.api.Utils;
public class GenericWhitespaceCheck extends Check
{
/** Used to count the depth of a Generic expression. */
private int mDepth;
private int depth;
@Override
public int[] getDefaultTokens()
@ -76,61 +76,61 @@ public class GenericWhitespaceCheck extends Check
}
@Override
public void beginTree(DetailAST aRootAST)
public void beginTree(DetailAST rootAST)
{
// Reset for each tree, just incase there are errors in preceeding
// trees.
mDepth = 0;
depth = 0;
}
@Override
public void visitToken(DetailAST aAST)
public void visitToken(DetailAST ast)
{
if (aAST.getType() == TokenTypes.GENERIC_START) {
processStart(aAST);
mDepth++;
if (ast.getType() == TokenTypes.GENERIC_START) {
processStart(ast);
depth++;
}
else if (aAST.getType() == TokenTypes.GENERIC_END) {
processEnd(aAST);
mDepth--;
else if (ast.getType() == TokenTypes.GENERIC_END) {
processEnd(ast);
depth--;
}
}
/**
* Checks the token for the end of Generics.
* @param aAST the token to check
* @param ast the token to check
*/
private void processEnd(DetailAST aAST)
private void processEnd(DetailAST ast)
{
final String line = getLine(aAST.getLineNo() - 1);
final int before = aAST.getColumnNo() - 1;
final int after = aAST.getColumnNo() + 1;
final String line = getLine(ast.getLineNo() - 1);
final int before = ast.getColumnNo() - 1;
final int after = ast.getColumnNo() + 1;
if ((0 <= before) && Character.isWhitespace(line.charAt(before))
&& !Utils.whitespaceBefore(before, line))
{
log(aAST.getLineNo(), before, "ws.preceded", ">");
log(ast.getLineNo(), before, "ws.preceded", ">");
}
if (after < line.length()) {
// Check if the last Generic, in which case must be a whitespace
// or a '(),[.'.
if (1 == mDepth) {
if (1 == depth) {
final char charAfter = line.charAt(after);
// Need to handle a number of cases. First is:
// Collections.<Object>emptySet();
// ^
// +--- whitespace not allowed
if ((aAST.getParent().getType() == TokenTypes.TYPE_ARGUMENTS)
&& (aAST.getParent().getParent().getType()
if ((ast.getParent().getType() == TokenTypes.TYPE_ARGUMENTS)
&& (ast.getParent().getParent().getType()
== TokenTypes.DOT)
&& (aAST.getParent().getParent().getParent().getType()
&& (ast.getParent().getParent().getParent().getType()
== TokenTypes.METHOD_CALL))
{
if (Character.isWhitespace(charAfter)) {
log(aAST.getLineNo(), after, "ws.followed", ">");
log(ast.getLineNo(), after, "ws.followed", ">");
}
}
else if (!Character.isWhitespace(charAfter)
@ -138,7 +138,7 @@ public class GenericWhitespaceCheck extends Check
&& (',' != charAfter) && ('[' != charAfter)
&& ('.' != charAfter) && (':' != charAfter))
{
log(aAST.getLineNo(), after, "ws.illegalFollow", ">");
log(ast.getLineNo(), after, "ws.illegalFollow", ">");
}
}
else {
@ -146,7 +146,7 @@ public class GenericWhitespaceCheck extends Check
// In case of several extends definitions:
//
// class IntEnumValueType<E extends Enum<E> & IntEnum>
// class IntEnuvalueType<E extends Enum<E> & IntEnum>
// ^
// should be whitespace if followed by & -+
//
@ -155,14 +155,14 @@ public class GenericWhitespaceCheck extends Check
&& whitespaceBetween(after, indexOfAmp, line))
{
if (indexOfAmp - after == 0) {
log(aAST.getLineNo(), after, "ws.notPreceded", "&");
log(ast.getLineNo(), after, "ws.notPreceded", "&");
}
else if (indexOfAmp - after != 1) {
log(aAST.getLineNo(), after, "ws.followed", ">");
log(ast.getLineNo(), after, "ws.followed", ">");
}
}
else if (line.charAt(after) == ' ') {
log(aAST.getLineNo(), after, "ws.followed", ">");
log(ast.getLineNo(), after, "ws.followed", ">");
}
}
}
@ -170,13 +170,13 @@ public class GenericWhitespaceCheck extends Check
/**
* Checks the token for the start of Generics.
* @param aAST the token to check
* @param ast the token to check
*/
private void processStart(DetailAST aAST)
private void processStart(DetailAST ast)
{
final String line = getLine(aAST.getLineNo() - 1);
final int before = aAST.getColumnNo() - 1;
final int after = aAST.getColumnNo() + 1;
final String line = getLine(ast.getLineNo() - 1);
final int before = ast.getColumnNo() - 1;
final int after = ast.getColumnNo() + 1;
// Need to handle two cases as in:
//
@ -186,7 +186,7 @@ public class GenericWhitespaceCheck extends Check
//
if (0 <= before) {
// Detect if the first case
final DetailAST parent = aAST.getParent();
final DetailAST parent = ast.getParent();
final DetailAST grandparent = parent.getParent();
if ((TokenTypes.TYPE_PARAMETERS == parent.getType())
&& ((TokenTypes.CTOR_DEF == grandparent.getType())
@ -194,21 +194,21 @@ public class GenericWhitespaceCheck extends Check
{
// Require whitespace
if (!Character.isWhitespace(line.charAt(before))) {
log(aAST.getLineNo(), before, "ws.notPreceded", "<");
log(ast.getLineNo(), before, "ws.notPreceded", "<");
}
}
// Whitespace not required
else if (Character.isWhitespace(line.charAt(before))
&& !Utils.whitespaceBefore(before, line))
{
log(aAST.getLineNo(), before, "ws.preceded", "<");
log(ast.getLineNo(), before, "ws.preceded", "<");
}
}
if ((after < line.length())
&& Character.isWhitespace(line.charAt(after)))
{
log(aAST.getLineNo(), after, "ws.followed", "<");
log(ast.getLineNo(), after, "ws.followed", "<");
}
}
@ -216,16 +216,16 @@ public class GenericWhitespaceCheck extends Check
* Returns whether the specified string contains only whitespace between
* specified indices.
*
* @param aFromIndex the index to start the search from. Inclusive
* @param aToIndex the index to finish the search. Exclusive
* @param aLine the line to check
* @param froindex the index to start the search from. Inclusive
* @param toIndex the index to finish the search. Exclusive
* @param line the line to check
* @return whether there are only whitespaces (or nothing)
*/
private static boolean whitespaceBetween(
int aFromIndex, int aToIndex, String aLine)
int froindex, int toIndex, String line)
{
for (int i = aFromIndex; i < aToIndex; i++) {
if (!Character.isWhitespace(aLine.charAt(i))) {
for (int i = froindex; i < toIndex; i++) {
if (!Character.isWhitespace(line.charAt(i))) {
return false;
}
}

View File

@ -45,14 +45,14 @@ import com.puppycrawl.tools.checkstyle.checks.AbstractOptionCheck;
* An example of how to configure the check is:
* </p>
* <pre>
* &lt;module name="MethodParamPad"/&gt;
* &lt;module name="MethodParapad"/&gt;
* </pre>
* <p> An example of how to configure the check to require a space
* after the identifier of a method definition, except if the left
* parenthesis occurs on a new line, is:
* </p>
* <pre>
* &lt;module name="MethodParamPad"&gt;
* &lt;module name="MethodParapad"&gt;
* &lt;property name="tokens" value="METHOD_DEF"/&gt;
* &lt;property name="option" value="space"/&gt;
* &lt;property name="allowLineBreaks" value="true"/&gt;
@ -75,7 +75,7 @@ public class MethodParamPadCheck
/** Whether whitespace is allowed if the method identifier is at a
* linebreak */
private boolean mAllowLineBreaks;
private boolean allowLineBreaks;
@Override
public int[] getDefaultTokens()
@ -90,14 +90,14 @@ public class MethodParamPadCheck
}
@Override
public void visitToken(DetailAST aAST)
public void visitToken(DetailAST ast)
{
final DetailAST parenAST;
if ((aAST.getType() == TokenTypes.METHOD_CALL)) {
parenAST = aAST;
if ((ast.getType() == TokenTypes.METHOD_CALL)) {
parenAST = ast;
}
else {
parenAST = aAST.findFirstToken(TokenTypes.LPAREN);
parenAST = ast.findFirstToken(TokenTypes.LPAREN);
// array construction => parenAST == null
if (parenAST == null) {
return;
@ -106,7 +106,7 @@ public class MethodParamPadCheck
final String line = getLines()[parenAST.getLineNo() - 1];
if (Utils.whitespaceBefore(parenAST.getColumnNo(), line)) {
if (!mAllowLineBreaks) {
if (!allowLineBreaks) {
log(parenAST, "line.previous", parenAST.getText());
}
}
@ -127,11 +127,11 @@ public class MethodParamPadCheck
/**
* Control whether whitespace is flagged at linebreaks.
* @param aAllowLineBreaks whether whitespace should be
* @param allowLineBreaks whether whitespace should be
* flagged at linebreaks.
*/
public void setAllowLineBreaks(boolean aAllowLineBreaks)
public void setAllowLineBreaks(boolean allowLineBreaks)
{
mAllowLineBreaks = aAllowLineBreaks;
this.allowLineBreaks = allowLineBreaks;
}
}

View File

@ -87,10 +87,10 @@ public class NoLineWrapCheck extends Check
}
@Override
public void visitToken(DetailAST aAST)
public void visitToken(DetailAST ast)
{
if (aAST.getLineNo() != aAST.getLastChild().getLineNo()) {
log(aAST.getLineNo(), "no.line.wrap", aAST.getText());
if (ast.getLineNo() != ast.getLastChild().getLineNo()) {
log(ast.getLineNo(), "no.line.wrap", ast.getText());
}
}
}

View File

@ -66,7 +66,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes;
public class NoWhitespaceAfterCheck extends Check
{
/** Whether whitespace is allowed if the AST is at a linebreak */
private boolean mAllowLineBreaks = true;
private boolean allowLineBreaks = true;
@Override
public int[] getDefaultTokens()
@ -102,67 +102,67 @@ public class NoWhitespaceAfterCheck extends Check
}
@Override
public void visitToken(DetailAST aAST)
public void visitToken(DetailAST ast)
{
DetailAST ast = aAST;
if (aAST.getType() == TokenTypes.ARRAY_DECLARATOR
|| aAST.getType() == TokenTypes.TYPECAST)
DetailAST astNode = ast;
if (ast.getType() == TokenTypes.ARRAY_DECLARATOR
|| ast.getType() == TokenTypes.TYPECAST)
{
ast = getPreceded(aAST);
astNode = getPreceded(ast);
}
final String line = getLine(aAST.getLineNo() - 1);
final int after = getPositionAfter(ast);
final String line = getLine(ast.getLineNo() - 1);
final int after = getPositionAfter(astNode);
if ((after >= line.length() || Character.isWhitespace(line.charAt(after)))
&& hasRedundantWhitespace(line, after))
{
log(ast.getLineNo(), after,
"ws.followed", ast.getText());
log(astNode.getLineNo(), after,
"ws.followed", astNode.getText());
}
}
/**
* Gets possible place where redundant whitespace could be.
* @param aArrayOrTypeCast {@link TokenTypes#ARRAY_DECLARATOR ARRAY_DECLARATOR}
* @param arrayOrTypeCast {@link TokenTypes#ARRAY_DECLARATOR ARRAY_DECLARATOR}
* or {@link TokenTypes#TYPECAST TYPECAST}.
* @return possible place of redundant whitespace.
*/
private static DetailAST getPreceded(DetailAST aArrayOrTypeCast)
private static DetailAST getPreceded(DetailAST arrayOrTypeCast)
{
DetailAST preceded = aArrayOrTypeCast;
switch (aArrayOrTypeCast.getType()) {
DetailAST preceded = arrayOrTypeCast;
switch (arrayOrTypeCast.getType()) {
case TokenTypes.TYPECAST:
preceded = aArrayOrTypeCast.findFirstToken(TokenTypes.RPAREN);
preceded = arrayOrTypeCast.findFirstToken(TokenTypes.RPAREN);
break;
case TokenTypes.ARRAY_DECLARATOR:
preceded = getArrayTypeOrIdentifier(aArrayOrTypeCast);
preceded = getArrayTypeOrIdentifier(arrayOrTypeCast);
break;
default:
throw new IllegalStateException(aArrayOrTypeCast.toString());
throw new IllegalStateException(arrayOrTypeCast.toString());
}
return preceded;
}
/**
* Gets position after token (place of possible redundant whitespace).
* @param aAST Node representing token.
* @param ast Node representing token.
* @return position after token.
*/
private static int getPositionAfter(DetailAST aAST)
private static int getPositionAfter(DetailAST ast)
{
int after;
//If target of possible redundant whitespace is in method definition
if (aAST.getType() == TokenTypes.IDENT
&& aAST.getNextSibling() != null
&& aAST.getNextSibling().getType() == TokenTypes.LPAREN)
if (ast.getType() == TokenTypes.IDENT
&& ast.getNextSibling() != null
&& ast.getNextSibling().getType() == TokenTypes.LPAREN)
{
final DetailAST methodDef = aAST.getParent();
final DetailAST methodDef = ast.getParent();
final DetailAST endOfParams = methodDef.findFirstToken(TokenTypes.RPAREN);
after = endOfParams.getColumnNo() + 1;
}
else {
after = aAST.getColumnNo() + aAST.getText().length();
after = ast.getColumnNo() + ast.getText().length();
}
return after;
}
@ -170,23 +170,23 @@ public class NoWhitespaceAfterCheck extends Check
/**
* Gets target place of possible redundant whitespace (array's type or identifier)
* after which {@link TokenTypes#ARRAY_DECLARATOR ARRAY_DECLARATOR} is set.
* @param aArrayDeclarator {@link TokenTypes#ARRAY_DECLARATOR ARRAY_DECLARATOR}
* @param arrayDeclarator {@link TokenTypes#ARRAY_DECLARATOR ARRAY_DECLARATOR}
* @return target place before possible redundant whitespace.
*/
private static DetailAST getArrayTypeOrIdentifier(DetailAST aArrayDeclarator)
private static DetailAST getArrayTypeOrIdentifier(DetailAST arrayDeclarator)
{
DetailAST typeOrIdent = aArrayDeclarator;
if (isArrayInstantiation(aArrayDeclarator)) {
typeOrIdent = aArrayDeclarator.getParent().getFirstChild();
DetailAST typeOrIdent = arrayDeclarator;
if (isArrayInstantiation(arrayDeclarator)) {
typeOrIdent = arrayDeclarator.getParent().getFirstChild();
}
else if (isMultiDimensionalArray(aArrayDeclarator)) {
if (isCstyleMultiDimensionalArrayDeclaration(aArrayDeclarator)) {
if (aArrayDeclarator.getParent().getType() != TokenTypes.ARRAY_DECLARATOR) {
typeOrIdent = getArrayIdentifier(aArrayDeclarator);
else if (isMultiDimensionalArray(arrayDeclarator)) {
if (isCstyleMultiDimensionalArrayDeclaration(arrayDeclarator)) {
if (arrayDeclarator.getParent().getType() != TokenTypes.ARRAY_DECLARATOR) {
typeOrIdent = getArrayIdentifier(arrayDeclarator);
}
}
else {
DetailAST arrayIdentifier = aArrayDeclarator.getFirstChild();
DetailAST arrayIdentifier = arrayDeclarator.getFirstChild();
while (arrayIdentifier != null) {
typeOrIdent = arrayIdentifier;
arrayIdentifier = arrayIdentifier.getFirstChild();
@ -194,11 +194,11 @@ public class NoWhitespaceAfterCheck extends Check
}
}
else {
if (isCstyleArrayDeclaration(aArrayDeclarator)) {
typeOrIdent = getArrayIdentifier(aArrayDeclarator);
if (isCstyleArrayDeclaration(arrayDeclarator)) {
typeOrIdent = getArrayIdentifier(arrayDeclarator);
}
else {
typeOrIdent = aArrayDeclarator.getFirstChild();
typeOrIdent = arrayDeclarator.getFirstChild();
}
}
return typeOrIdent;
@ -214,43 +214,43 @@ public class NoWhitespaceAfterCheck extends Check
* <p>
* someArray is identifier.
* </p>
* @param aArrayDeclarator {@link TokenTypes#ARRAY_DECLARATOR ARRAY_DECLARATOR}
* @param arrayDeclarator {@link TokenTypes#ARRAY_DECLARATOR ARRAY_DECLARATOR}
* @return array identifier.
*/
private static DetailAST getArrayIdentifier(DetailAST aArrayDeclarator)
private static DetailAST getArrayIdentifier(DetailAST arrayDeclarator)
{
return aArrayDeclarator.getParent().getNextSibling();
return arrayDeclarator.getParent().getNextSibling();
}
/**
* Checks if current array is multidimensional.
* @param aArrayDeclaration {@link TokenTypes#ARRAY_DECLARATOR ARRAY_DECLARATOR}
* @param arrayDeclaration {@link TokenTypes#ARRAY_DECLARATOR ARRAY_DECLARATOR}
* @return true if current array is multidimensional.
*/
private static boolean isMultiDimensionalArray(DetailAST aArrayDeclaration)
private static boolean isMultiDimensionalArray(DetailAST arrayDeclaration)
{
return aArrayDeclaration.getParent().getType() == TokenTypes.ARRAY_DECLARATOR
|| aArrayDeclaration.getFirstChild().getType() == TokenTypes.ARRAY_DECLARATOR;
return arrayDeclaration.getParent().getType() == TokenTypes.ARRAY_DECLARATOR
|| arrayDeclaration.getFirstChild().getType() == TokenTypes.ARRAY_DECLARATOR;
}
/**
* Checks if current array declaration is part of array instantiation.
* @param aArrayDeclaration {@link TokenTypes#ARRAY_DECLARATOR ARRAY_DECLARATOR}
* @param arrayDeclaration {@link TokenTypes#ARRAY_DECLARATOR ARRAY_DECLARATOR}
* @return true if current array declaration is part of array instantiation.
*/
private static boolean isArrayInstantiation(DetailAST aArrayDeclaration)
private static boolean isArrayInstantiation(DetailAST arrayDeclaration)
{
return aArrayDeclaration.getParent().getType() == TokenTypes.LITERAL_NEW;
return arrayDeclaration.getParent().getType() == TokenTypes.LITERAL_NEW;
}
/**
* Control whether whitespace is flagged at linebreaks.
* @param aAllowLineBreaks whether whitespace should be
* @param allowLineBreaks whether whitespace should be
* flagged at linebreaks.
*/
public void setAllowLineBreaks(boolean aAllowLineBreaks)
public void setAllowLineBreaks(boolean allowLineBreaks)
{
mAllowLineBreaks = aAllowLineBreaks;
this.allowLineBreaks = allowLineBreaks;
}
/**
@ -265,15 +265,15 @@ public class NoWhitespaceAfterCheck extends Check
* int[] array = { ... }; //Java style
* </code>
* </p>
* @param aArrayDeclaration {@link TokenTypes#ARRAY_DECLARATOR ARRAY_DECLARATOR}
* @param arrayDeclaration {@link TokenTypes#ARRAY_DECLARATOR ARRAY_DECLARATOR}
* @return true if array is declared in C style
*/
private static boolean isCstyleArrayDeclaration(DetailAST aArrayDeclaration)
private static boolean isCstyleArrayDeclaration(DetailAST arrayDeclaration)
{
boolean result = false;
final DetailAST identifier = getArrayIdentifier(aArrayDeclaration);
final DetailAST identifier = getArrayIdentifier(arrayDeclaration);
if (identifier != null) {
final int arrayDeclarationStart = aArrayDeclaration.getColumnNo();
final int arrayDeclarationStart = arrayDeclaration.getColumnNo();
final int identifierEnd = identifier.getColumnNo() + identifier.getText().length();
result = arrayDeclarationStart == identifierEnd
|| arrayDeclarationStart > identifierEnd;
@ -283,13 +283,13 @@ public class NoWhitespaceAfterCheck extends Check
/**
* Works with multidimensional arrays.
* @param aArrayDeclaration {@link TokenTypes#ARRAY_DECLARATOR ARRAY_DECLARATOR}
* @param arrayDeclaration {@link TokenTypes#ARRAY_DECLARATOR ARRAY_DECLARATOR}
* @return true if multidimensional array is declared in C style.
*/
private static boolean isCstyleMultiDimensionalArrayDeclaration(DetailAST aArrayDeclaration)
private static boolean isCstyleMultiDimensionalArrayDeclaration(DetailAST arrayDeclaration)
{
boolean result = false;
DetailAST parentArrayDeclaration = aArrayDeclaration;
DetailAST parentArrayDeclaration = arrayDeclaration;
while (parentArrayDeclaration != null) {
if (parentArrayDeclaration.getParent() != null
&& parentArrayDeclaration.getParent().getType() == TokenTypes.TYPE)
@ -303,15 +303,15 @@ public class NoWhitespaceAfterCheck extends Check
/**
* Checks if current line has redundant whitespace after specified index.
* @param aLine line of java source.
* @param aAfter specified index.
* @param line line of java source.
* @param after specified index.
* @return true if line contains redundant whitespace.
*/
private boolean hasRedundantWhitespace(String aLine, int aAfter)
private boolean hasRedundantWhitespace(String line, int after)
{
boolean result = !mAllowLineBreaks;
for (int i = aAfter + 1; !result && (i < aLine.length()); i++) {
if (!Character.isWhitespace(aLine.charAt(i))) {
boolean result = !allowLineBreaks;
for (int i = after + 1; !result && (i < line.length()); i++) {
if (!Character.isWhitespace(line.charAt(i))) {
result = true;
}
}

View File

@ -62,7 +62,7 @@ public class NoWhitespaceBeforeCheck
extends Check
{
/** Whether whitespace is allowed if the AST is at a linebreak */
private boolean mAllowLineBreaks;
private boolean allowLineBreaks;
@Override
public int[] getDefaultTokens()
@ -86,16 +86,16 @@ public class NoWhitespaceBeforeCheck
}
@Override
public void visitToken(DetailAST aAST)
public void visitToken(DetailAST ast)
{
final String line = getLine(aAST.getLineNo() - 1);
final int before = aAST.getColumnNo() - 1;
final String line = getLine(ast.getLineNo() - 1);
final int before = ast.getColumnNo() - 1;
if ((before < 0) || Character.isWhitespace(line.charAt(before))) {
// empty FOR initializer?
if (aAST.getType() == TokenTypes.SEMI) {
final DetailAST sibling = aAST.getPreviousSibling();
if (ast.getType() == TokenTypes.SEMI) {
final DetailAST sibling = ast.getPreviousSibling();
if ((sibling != null)
&& (sibling.getType() == TokenTypes.FOR_INIT)
&& (sibling.getChildCount() == 0))
@ -104,7 +104,7 @@ public class NoWhitespaceBeforeCheck
}
}
boolean flag = !mAllowLineBreaks;
boolean flag = !allowLineBreaks;
// verify all characters before '.' are whitespace
for (int i = 0; !flag && (i < before); i++) {
if (!Character.isWhitespace(line.charAt(i))) {
@ -112,18 +112,18 @@ public class NoWhitespaceBeforeCheck
}
}
if (flag) {
log(aAST.getLineNo(), before, "ws.preceded", aAST.getText());
log(ast.getLineNo(), before, "ws.preceded", ast.getText());
}
}
}
/**
* Control whether whitespace is flagged at linebreaks.
* @param aAllowLineBreaks whether whitespace should be
* @param allowLineBreaks whether whitespace should be
* flagged at linebreaks.
*/
public void setAllowLineBreaks(boolean aAllowLineBreaks)
public void setAllowLineBreaks(boolean allowLineBreaks)
{
mAllowLineBreaks = aAllowLineBreaks;
this.allowLineBreaks = allowLineBreaks;
}
}

View File

@ -172,10 +172,10 @@ public class OperatorWrapCheck
}
@Override
public void visitToken(DetailAST aAST)
public void visitToken(DetailAST ast)
{
if (aAST.getType() == TokenTypes.COLON) {
final DetailAST parent = aAST.getParent();
if (ast.getType() == TokenTypes.COLON) {
final DetailAST parent = ast.getParent();
if ((parent.getType() == TokenTypes.LITERAL_DEFAULT)
|| (parent.getType() == TokenTypes.LITERAL_CASE))
{
@ -185,9 +185,9 @@ public class OperatorWrapCheck
}
final WrapOption wOp = getAbstractOption();
final String text = aAST.getText();
final int colNo = aAST.getColumnNo();
final int lineNo = aAST.getLineNo();
final String text = ast.getText();
final int colNo = ast.getColumnNo();
final int lineNo = ast.getLineNo();
final String currentLine = getLine(lineNo - 1);
// TODO: Handle comments before and after operator

View File

@ -76,9 +76,9 @@ public class ParenPadCheck extends AbstractParenPadCheck
}
@Override
public void visitToken(DetailAST aAST)
public void visitToken(DetailAST ast)
{
DetailAST theAst = aAST;
DetailAST theAst = ast;
// Strange logic in this method to guard against checking RPAREN tokens
// that are associated with a TYPECAST token.
if (theAst.getType() != TokenTypes.RPAREN) {
@ -102,13 +102,13 @@ public class ParenPadCheck extends AbstractParenPadCheck
}
/**
* @param aAST the token to check
* @param ast the token to check
* @return whether a token follows an empty for iterator
*/
private boolean isFollowsEmptyForIterator(DetailAST aAST)
private boolean isFollowsEmptyForIterator(DetailAST ast)
{
boolean followsEmptyForIterator = false;
final DetailAST parent = aAST.getParent();
final DetailAST parent = ast.getParent();
//Only traditional for statements are examined, not for-each statements
if ((parent != null)
&& (parent.getType() == TokenTypes.LITERAL_FOR)
@ -117,19 +117,19 @@ public class ParenPadCheck extends AbstractParenPadCheck
final DetailAST forIterator =
parent.findFirstToken(TokenTypes.FOR_ITERATOR);
followsEmptyForIterator = (forIterator.getChildCount() == 0)
&& (aAST == forIterator.getNextSibling());
&& (ast == forIterator.getNextSibling());
}
return followsEmptyForIterator;
}
/**
* @param aAST the token to check
* @param ast the token to check
* @return whether a token preceeds an empty for initializer
*/
private boolean isPreceedsEmptyForInit(DetailAST aAST)
private boolean isPreceedsEmptyForInit(DetailAST ast)
{
boolean preceedsEmptyForInintializer = false;
final DetailAST parent = aAST.getParent();
final DetailAST parent = ast.getParent();
//Only traditional for statements are examined, not for-each statements
if ((parent != null)
&& (parent.getType() == TokenTypes.LITERAL_FOR)
@ -138,7 +138,7 @@ public class ParenPadCheck extends AbstractParenPadCheck
final DetailAST forIterator =
parent.findFirstToken(TokenTypes.FOR_INIT);
preceedsEmptyForInintializer = (forIterator.getChildCount() == 0)
&& (aAST == forIterator.getPreviousSibling());
&& (ast == forIterator.getPreviousSibling());
}
return preceedsEmptyForInintializer;
}

View File

@ -114,13 +114,13 @@ public class SeparatorWrapCheck
}
@Override
public void visitToken(DetailAST aAST)
public void visitToken(DetailAST ast)
{
// TODO: It is a copy/paste from OperatorWrapCheck.
//It should be fixed in another issue
final String text = aAST.getText();
final int colNo = aAST.getColumnNo();
final int lineNo = aAST.getLineNo();
final String text = ast.getText();
final int colNo = ast.getColumnNo();
final int lineNo = ast.getLineNo();
final String currentLine = getLines()[lineNo - 1];
final String substringAfterToken =
currentLine.substring(colNo + text.length()).trim();

View File

@ -63,19 +63,19 @@ public class TypecastParenPadCheck extends AbstractParenPadCheck
}
@Override
public void visitToken(DetailAST aAST)
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 (aAST.getType() == TokenTypes.TYPECAST) {
processLeft(aAST);
if (ast.getType() == TokenTypes.TYPECAST) {
processLeft(ast);
}
else if ((aAST.getParent() != null)
&& (aAST.getParent().getType() == TokenTypes.TYPECAST)
&& (aAST.getParent().findFirstToken(TokenTypes.RPAREN)
== aAST))
else if ((ast.getParent() != null)
&& (ast.getParent().getType() == TokenTypes.TYPECAST)
&& (ast.getParent().findFirstToken(TokenTypes.RPAREN)
== ast))
{
processRight(aAST);
processRight(ast);
}
}
}

View File

@ -66,18 +66,18 @@ public class WhitespaceAfterCheck
}
@Override
public void visitToken(DetailAST aAST)
public void visitToken(DetailAST ast)
{
final Object[] message;
final DetailAST targetAST;
if (aAST.getType() == TokenTypes.TYPECAST) {
targetAST = aAST.findFirstToken(TokenTypes.RPAREN);
if (ast.getType() == TokenTypes.TYPECAST) {
targetAST = ast.findFirstToken(TokenTypes.RPAREN);
// TODO: i18n
message = new Object[]{"cast"};
}
else {
targetAST = aAST;
message = new Object[]{aAST.getText()};
targetAST = ast;
message = new Object[]{ast.getText()};
}
final String line = getLine(targetAST.getLineNo() - 1);
final int after =

View File

@ -158,15 +158,15 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes;
public class WhitespaceAroundCheck extends Check
{
/** Whether or not empty constructor bodies are allowed. */
private boolean mAllowEmptyCtors;
private boolean allowEmptyCtors;
/** Whether or not empty method bodies are allowed. */
private boolean mAllowEmptyMethods;
private boolean allowEmptyMethods;
/** Whether or not empty classes, enums and interfaces are allowed*/
private boolean mAllowEmptyTypes;
private boolean allowEmptyTypes;
/** Whether or not empty loops are allowed*/
private boolean mAllowEmptyLoops;
private boolean allowEmptyLoops;
/** whether or not to ignore a colon in a enhanced for loop */
private boolean mIgnoreEnhancedForColon = true;
private boolean ignoreEnhancedForColon = true;
@Override
public int[] getDefaultTokens()
@ -227,55 +227,55 @@ public class WhitespaceAroundCheck extends Check
/**
* Sets whether or not empty method bodies are allowed.
* @param aAllow <code>true</code> to allow empty method bodies.
* @param allow <code>true</code> to allow empty method bodies.
*/
public void setAllowEmptyMethods(boolean aAllow)
public void setAllowEmptyMethods(boolean allow)
{
mAllowEmptyMethods = aAllow;
allowEmptyMethods = allow;
}
/**
* Sets whether or not empty constructor bodies are allowed.
* @param aAllow <code>true</code> to allow empty constructor bodies.
* @param allow <code>true</code> to allow empty constructor bodies.
*/
public void setAllowEmptyConstructors(boolean aAllow)
public void setAllowEmptyConstructors(boolean allow)
{
mAllowEmptyCtors = aAllow;
allowEmptyCtors = allow;
}
/**
* Sets whether or not to ignore the whitespace around the
* colon in an enhanced for loop.
* @param aIgnore <code>true</code> to ignore enhanced for colon.
* @param ignore <code>true</code> to ignore enhanced for colon.
*/
public void setIgnoreEnhancedForColon(boolean aIgnore)
public void setIgnoreEnhancedForColon(boolean ignore)
{
mIgnoreEnhancedForColon = aIgnore;
ignoreEnhancedForColon = ignore;
}
/**
* Sets whether or not empty type bodies are allowed.
* @param aAllow <code>true</code> to allow empty type bodies.
* @param allow <code>true</code> to allow empty type bodies.
*/
public void setAllowEmptyTypes(boolean aAllow)
public void setAllowEmptyTypes(boolean allow)
{
mAllowEmptyTypes = aAllow;
allowEmptyTypes = allow;
}
/**
* Sets whether or not empty loop bodies are allowed.
* @param aAllow <code>true</code> to allow empty loops bodies.
* @param allow <code>true</code> to allow empty loops bodies.
*/
public void setAllowEmptyLoops(boolean aAllow)
public void setAllowEmptyLoops(boolean allow)
{
mAllowEmptyLoops = aAllow;
allowEmptyLoops = allow;
}
@Override
public void visitToken(DetailAST aAST)
public void visitToken(DetailAST ast)
{
final int currentType = aAST.getType();
final int parentType = aAST.getParent().getType();
final int currentType = ast.getType();
final int parentType = ast.getParent().getType();
// Check for CURLY in array initializer
if (((currentType == TokenTypes.RCURLY)
@ -308,32 +308,32 @@ public class WhitespaceAroundCheck extends Check
return;
}
else if (parentType == TokenTypes.FOR_EACH_CLAUSE
&& this.mIgnoreEnhancedForColon)
&& this.ignoreEnhancedForColon)
{
return;
}
}
// Checks if empty methods, ctors or loops are allowed.
if (isEmptyMethodBlock(aAST, parentType)
|| isEmptyCtorBlock(aAST, parentType)
|| isEmptyLoop(aAST, parentType))
if (isEmptyMethodBlock(ast, parentType)
|| isEmptyCtorBlock(ast, parentType)
|| isEmptyLoop(ast, parentType))
{
return;
}
// Checks if empty classes, interfaces or enums are allowed
if (mAllowEmptyTypes && (isEmptyType(aAST, parentType))) {
if (allowEmptyTypes && (isEmptyType(ast, parentType))) {
return;
}
final String line = getLine(aAST.getLineNo() - 1);
final int before = aAST.getColumnNo() - 1;
final int after = aAST.getColumnNo() + aAST.getText().length();
final String line = getLine(ast.getLineNo() - 1);
final int before = ast.getColumnNo() - 1;
final int after = ast.getColumnNo() + ast.getText().length();
if ((before >= 0) && !Character.isWhitespace(line.charAt(before))) {
log(aAST.getLineNo(), aAST.getColumnNo(),
"ws.notPreceded", aAST.getText());
log(ast.getLineNo(), ast.getColumnNo(),
"ws.notPreceded", ast.getText());
}
if (after >= line.length()) {
@ -344,7 +344,7 @@ public class WhitespaceAroundCheck extends Check
if (!Character.isWhitespace(nextChar)
// Check for "return;"
&& !((currentType == TokenTypes.LITERAL_RETURN)
&& (aAST.getFirstChild().getType() == TokenTypes.SEMI))
&& (ast.getFirstChild().getType() == TokenTypes.SEMI))
// Check for "})" or "};" or "},". Happens with anon-inners
&& !((currentType == TokenTypes.RCURLY)
&& ((nextChar == ')')
@ -352,54 +352,54 @@ public class WhitespaceAroundCheck extends Check
|| (nextChar == ',')
|| (nextChar == '.'))))
{
log(aAST.getLineNo(), aAST.getColumnNo() + aAST.getText().length(),
"ws.notFollowed", aAST.getText());
log(ast.getLineNo(), ast.getColumnNo() + ast.getText().length(),
"ws.notFollowed", ast.getText());
}
}
/**
* Test if the given <code>DetailAST</code> is part of an allowed empty
* method block.
* @param aAST the <code>DetailAST</code> to test.
* @param aParentType the token type of <code>aAST</code>'s parent.
* @return <code>true</code> if <code>aAST</code> makes up part of an
* @param ast the <code>DetailAST</code> to test.
* @param parentType the token type of <code>ast</code>'s parent.
* @return <code>true</code> if <code>ast</code> makes up part of an
* allowed empty method block.
*/
private boolean isEmptyMethodBlock(DetailAST aAST, int aParentType)
private boolean isEmptyMethodBlock(DetailAST ast, int parentType)
{
return mAllowEmptyMethods
&& isEmptyBlock(aAST, aParentType, TokenTypes.METHOD_DEF);
return allowEmptyMethods
&& isEmptyBlock(ast, parentType, TokenTypes.METHOD_DEF);
}
/**
* Test if the given <code>DetailAST</code> is part of an allowed empty
* constructor (ctor) block.
* @param aAST the <code>DetailAST</code> to test.
* @param aParentType the token type of <code>aAST</code>'s parent.
* @return <code>true</code> if <code>aAST</code> makes up part of an
* @param ast the <code>DetailAST</code> to test.
* @param parentType the token type of <code>ast</code>'s parent.
* @return <code>true</code> if <code>ast</code> makes up part of an
* allowed empty constructor block.
*/
private boolean isEmptyCtorBlock(DetailAST aAST, int aParentType)
private boolean isEmptyCtorBlock(DetailAST ast, int parentType)
{
return mAllowEmptyCtors
&& isEmptyBlock(aAST, aParentType, TokenTypes.CTOR_DEF);
return allowEmptyCtors
&& isEmptyBlock(ast, parentType, TokenTypes.CTOR_DEF);
}
/**
*
* @param aAST aAST the <code>DetailAST</code> to test.
* @param aParentType the token type of <code>aAST</code>'s parent.
* @return <code>true</code> if <code>aAST</code> makes up part of an
* @param ast ast the <code>DetailAST</code> to test.
* @param parentType the token type of <code>ast</code>'s parent.
* @return <code>true</code> if <code>ast</code> makes up part of an
* allowed empty loop block.
*/
private boolean isEmptyLoop(DetailAST aAST, int aParentType)
private boolean isEmptyLoop(DetailAST ast, int parentType)
{
return mAllowEmptyLoops
&& (isEmptyBlock(aAST, aParentType, TokenTypes.LITERAL_FOR)
|| isEmptyBlock(aAST,
aParentType, TokenTypes.LITERAL_WHILE)
|| isEmptyBlock(aAST,
aParentType, TokenTypes.LITERAL_DO));
return allowEmptyLoops
&& (isEmptyBlock(ast, parentType, TokenTypes.LITERAL_FOR)
|| isEmptyBlock(ast,
parentType, TokenTypes.LITERAL_WHILE)
|| isEmptyBlock(ast,
parentType, TokenTypes.LITERAL_DO));
}
/**
@ -409,19 +409,19 @@ public class WhitespaceAroundCheck extends Check
* <pre> class Foo {}</pre>
* </p>
*
* @param aAST aAST the <code>DetailAST</code> to test.
* @param aParentType the token type of <code>aAST</code>'s parent.
* @return <code>true</code> if <code>aAST</code> makes up part of an
* empty block contained under a <code>aMatch</code> token type
* @param ast ast the <code>DetailAST</code> to test.
* @param parentType the token type of <code>ast</code>'s parent.
* @return <code>true</code> if <code>ast</code> makes up part of an
* empty block contained under a <code>match</code> token type
* node.
*/
private boolean isEmptyType(DetailAST aAST, int aParentType)
private boolean isEmptyType(DetailAST ast, int parentType)
{
final int type = aAST.getType();
final int type = ast.getType();
if ((type == TokenTypes.RCURLY || type == TokenTypes.LCURLY)
&& aParentType == TokenTypes.OBJBLOCK)
&& parentType == TokenTypes.OBJBLOCK)
{
final DetailAST typeNode = aAST.getParent().getParent();
final DetailAST typeNode = ast.getParent().getParent();
final int matchType = typeNode.getType();
if (matchType == TokenTypes.CLASS_DEF
|| matchType == TokenTypes.INTERFACE_DEF
@ -443,24 +443,24 @@ public class WhitespaceAroundCheck extends Check
* </p>
* In the above, the method body is an empty block ("{}").
*
* @param aAST the <code>DetailAST</code> to test.
* @param aParentType the token type of <code>aAST</code>'s parent.
* @param aMatch the parent token type we're looking to match.
* @return <code>true</code> if <code>aAST</code> makes up part of an
* empty block contained under a <code>aMatch</code> token type
* @param ast the <code>DetailAST</code> to test.
* @param parentType the token type of <code>ast</code>'s parent.
* @param match the parent token type we're looking to match.
* @return <code>true</code> if <code>ast</code> makes up part of an
* empty block contained under a <code>match</code> token type
* node.
*/
private boolean isEmptyBlock(DetailAST aAST, int aParentType, int aMatch)
private boolean isEmptyBlock(DetailAST ast, int parentType, int match)
{
final int type = aAST.getType();
final int type = ast.getType();
if (type == TokenTypes.RCURLY) {
final DetailAST grandParent = aAST.getParent().getParent();
return (aParentType == TokenTypes.SLIST)
&& (grandParent.getType() == aMatch);
final DetailAST grandParent = ast.getParent().getParent();
return (parentType == TokenTypes.SLIST)
&& (grandParent.getType() == match);
}
return (type == TokenTypes.SLIST)
&& (aParentType == aMatch)
&& (aAST.getFirstChild().getType() == TokenTypes.RCURLY);
&& (parentType == match)
&& (ast.getFirstChild().getType() == TokenTypes.RCURLY);
}
}

View File

@ -26,12 +26,12 @@ import org.junit.Test;
public class EmptyForInitializerPadCheckTest
extends BaseCheckTestSupport
{
private DefaultConfiguration mCheckConfig;
private DefaultConfiguration checkConfig;
@Before
public void setUp()
{
mCheckConfig = createCheckConfig(EmptyForInitializerPadCheck.class);
checkConfig = createCheckConfig(EmptyForInitializerPadCheck.class);
}
@Test
@ -40,16 +40,16 @@ public class EmptyForInitializerPadCheckTest
final String[] expected = {
"48:14: ';' is preceded with whitespace.",
};
verify(mCheckConfig, getPath("InputForWhitespace.java"), expected);
verify(checkConfig, getPath("InputForWhitespace.java"), expected);
}
@Test
public void testSpaceOption() throws Exception
{
mCheckConfig.addAttribute("option", PadOption.SPACE.toString());
checkConfig.addAttribute("option", PadOption.SPACE.toString());
final String[] expected = {
"51:13: ';' is not preceded with whitespace.",
};
verify(mCheckConfig, getPath("InputForWhitespace.java"), expected);
verify(checkConfig, getPath("InputForWhitespace.java"), expected);
}
}

View File

@ -26,12 +26,12 @@ import org.junit.Test;
public class EmptyForIteratorPadCheckTest
extends BaseCheckTestSupport
{
private DefaultConfiguration mCheckConfig;
private DefaultConfiguration checkConfig;
@Before
public void setUp()
{
mCheckConfig = createCheckConfig(EmptyForIteratorPadCheck.class);
checkConfig = createCheckConfig(EmptyForIteratorPadCheck.class);
}
@Test
@ -41,16 +41,16 @@ public class EmptyForIteratorPadCheckTest
"27:31: ';' is followed by whitespace.",
"43:32: ';' is followed by whitespace.",
};
verify(mCheckConfig, getPath("InputForWhitespace.java"), expected);
verify(checkConfig, getPath("InputForWhitespace.java"), expected);
}
@Test
public void testSpaceOption() throws Exception
{
mCheckConfig.addAttribute("option", PadOption.SPACE.toString());
checkConfig.addAttribute("option", PadOption.SPACE.toString());
final String[] expected = {
"23:31: ';' is not followed by whitespace.",
};
verify(mCheckConfig, getPath("InputForWhitespace.java"), expected);
verify(checkConfig, getPath("InputForWhitespace.java"), expected);
}
}

View File

@ -29,10 +29,10 @@ public class FileTabCharacterCheckTest
{
@Override
protected DefaultConfiguration createCheckerConfig(
Configuration aCheckConfig)
Configuration checkConfig)
{
final DefaultConfiguration dc = new DefaultConfiguration("root");
dc.addChild(aCheckConfig);
dc.addChild(checkConfig);
return dc;
}

View File

@ -31,12 +31,12 @@ import org.junit.Test;
public class GenericWhitespaceCheckTest
extends BaseCheckTestSupport
{
private DefaultConfiguration mCheckConfig;
private DefaultConfiguration checkConfig;
@Before
public void setUp()
{
mCheckConfig = createCheckConfig(GenericWhitespaceCheck.class);
checkConfig = createCheckConfig(GenericWhitespaceCheck.class);
Map<Class<?>, Integer> x = Maps.newHashMap();
for (final Map.Entry<Class<?>, Integer> entry : x.entrySet()) {
entry.getValue();
@ -75,7 +75,7 @@ public class GenericWhitespaceCheckTest
"60:60: '&' is not preceded with whitespace.",
"63:60: '>' is followed by whitespace.",
};
verify(mCheckConfig,
verify(checkConfig,
getPath("whitespace/InputGenericWhitespaceCheck.java"),
expected);
}
@ -84,7 +84,7 @@ public class GenericWhitespaceCheckTest
public void testGh47() throws Exception
{
final String[] expected = {};
verify(mCheckConfig, getPath("whitespace/Gh47.java"), expected);
verify(checkConfig, getPath("whitespace/Gh47.java"), expected);
}
@Test
@ -93,7 +93,7 @@ public class GenericWhitespaceCheckTest
final String[] expected = {
};
verify(mCheckConfig, getPath("whitespace/"
verify(checkConfig, getPath("whitespace/"
+ "InputGenericWhitespaceInnerClassCheck.java"), expected);
}
@ -101,7 +101,7 @@ public class GenericWhitespaceCheckTest
public void testMethodReferences() throws Exception
{
final String[] expected = {};
verify(mCheckConfig, new File("src/test/resources-noncompilable/com/puppycrawl/tools/"
verify(checkConfig, new File("src/test/resources-noncompilable/com/puppycrawl/tools/"
+ "checkstyle/grammars/java8/"
+ "InputMethodReferencesTest3.java").getCanonicalPath(), expected);
}

View File

@ -26,12 +26,12 @@ import org.junit.Test;
public class WhitespaceAfterCheckTest
extends BaseCheckTestSupport
{
private DefaultConfiguration mCheckConfig;
private DefaultConfiguration checkConfig;
@Before
public void setUp()
{
mCheckConfig = createCheckConfig(WhitespaceAfterCheck.class);
checkConfig = createCheckConfig(WhitespaceAfterCheck.class);
}
@Test
@ -41,7 +41,7 @@ public class WhitespaceAfterCheckTest
"42:40: ',' is not followed by whitespace.",
"71:30: ',' is not followed by whitespace.",
};
verify(mCheckConfig, getPath("InputSimple.java"), expected);
verify(checkConfig, getPath("InputSimple.java"), expected);
}
@Test
@ -50,7 +50,7 @@ public class WhitespaceAfterCheckTest
final String[] expected = {
"88:21: 'cast' is not followed by whitespace.",
};
verify(mCheckConfig, getPath("InputWhitespace.java"), expected);
verify(checkConfig, getPath("InputWhitespace.java"), expected);
}
@Test
@ -61,7 +61,7 @@ public class WhitespaceAfterCheckTest
"58:29: ';' is not followed by whitespace.",
"107:19: ';' is not followed by whitespace.",
};
verify(mCheckConfig, getPath("InputBraces.java"), expected);
verify(checkConfig, getPath("InputBraces.java"), expected);
}
@Test
@ -71,7 +71,7 @@ public class WhitespaceAfterCheckTest
"14:31: ';' is not followed by whitespace.",
"17:31: ';' is not followed by whitespace.",
};
verify(mCheckConfig, getPath("InputForWhitespace.java"), expected);
verify(checkConfig, getPath("InputForWhitespace.java"), expected);
}
@Test
@ -82,7 +82,7 @@ public class WhitespaceAfterCheckTest
"11:23: ',' is not followed by whitespace.",
"11:41: ',' is not followed by whitespace.",
};
verify(mCheckConfig, getPath("InputGenerics.java"), expected);
verify(checkConfig, getPath("InputGenerics.java"), expected);
}
@Test
@ -90,7 +90,7 @@ public class WhitespaceAfterCheckTest
{
final String[] expected = {
};
verify(mCheckConfig, getPath("whitespace/InputWhitespaceAround.java"),
verify(checkConfig, getPath("whitespace/InputWhitespaceAround.java"),
expected);
}
}