Merge
This commit is contained in:
commit
3852e12bec
|
|
@ -106,8 +106,27 @@ public class GenericWhitespaceCheck extends Check
|
|||
}
|
||||
}
|
||||
else {
|
||||
// In a nested Generic type, so can only be a '>' or ','
|
||||
if ((line.charAt(after) != '>') && (line.charAt(after) != ','))
|
||||
// In a nested Generic type, so can only be a '>' or ',' or '&'
|
||||
|
||||
// In case of several extends definitions:
|
||||
//
|
||||
// class IntEnumValueType<E extends Enum<E> & IntEnum>
|
||||
// ^
|
||||
// should be whitespace if followed by & -+
|
||||
//
|
||||
int indexOfAmp = line.indexOf('&', after);
|
||||
if ((indexOfAmp != -1) && whitespaceBetween(after, indexOfAmp, line))
|
||||
{
|
||||
if (indexOfAmp - after == 0)
|
||||
{
|
||||
log(aAST.getLineNo(), after, "ws.notPreceded", "&");
|
||||
}
|
||||
else if (indexOfAmp - after != 1)
|
||||
{
|
||||
log(aAST.getLineNo(), after, "ws.followed", ">");
|
||||
}
|
||||
}
|
||||
else if ((line.charAt(after) != '>') && (line.charAt(after) != ','))
|
||||
{
|
||||
log(aAST.getLineNo(), after, "ws.followed", ">");
|
||||
}
|
||||
|
|
@ -158,4 +177,25 @@ public class GenericWhitespaceCheck extends Check
|
|||
log(aAST.getLineNo(), after, "ws.followed", "<");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the specified string contains only whitespace between
|
||||
* specified indices.
|
||||
*
|
||||
* @param fromIndex the index to start the search from. Inclusive
|
||||
* @param toIndex the index to finish the search. Exclusive
|
||||
* @param aLine the line to check
|
||||
* @return whether there are only whitespaces (or nothing)
|
||||
*/
|
||||
private static boolean whitespaceBetween(int fromIndex, int toIndex, String aLine)
|
||||
{
|
||||
for (int i = fromIndex; i < toIndex; i++)
|
||||
{
|
||||
if (!Character.isWhitespace(aLine.charAt(i)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,4 +50,16 @@ class InputGenericWhitespaceCheck implements Comparable<InputGenericWhitespaceCh
|
|||
public <T> InputGenericWhitespaceCheck(List<T> things)
|
||||
{
|
||||
}
|
||||
|
||||
public interface IntEnum {
|
||||
}
|
||||
|
||||
public static class IntEnumValueType<E extends Enum<E> & IntEnum> {
|
||||
}
|
||||
|
||||
public static class IntEnumValueType<E extends Enum<E>& IntEnum> {
|
||||
}
|
||||
|
||||
public static class IntEnumValueType<E extends Enum<E> & IntEnum> {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,8 @@ public class GenericWhitespaceCheckTest
|
|||
"30:21: '>' is followed by an illegal character.",
|
||||
"42:21: '<' is preceded with whitespace.",
|
||||
"42:30: '>' is followed by whitespace.",
|
||||
"60:59: '&' is not preceded with whitespace.",
|
||||
"63:59: '>' is followed by whitespace.",
|
||||
};
|
||||
verify(mCheckConfig,
|
||||
getPath("whitespace/InputGenericWhitespaceCheck.java"),
|
||||
|
|
|
|||
Loading…
Reference in New Issue