Added another edge case.

This commit is contained in:
Oliver Burn 2007-12-17 12:02:07 +00:00
parent 325b265cc5
commit 1fe8bcab1a
3 changed files with 38 additions and 24 deletions

View File

@ -91,8 +91,9 @@ public class GenericWhitespaceCheck extends Check
}
}
else {
// In a nested Generic type, so can only be a '>'
if (line.charAt(after) != '>') {
// In a nested Generic type, so can only be a '>' or ','
if ((line.charAt(after) != '>') && (line.charAt(after) != ','))
{
log(aAST.getLineNo(), after, "ws.followed", ">");
}
}

View File

@ -2,7 +2,9 @@ package com.puppycrawl.tools.checkstyle;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
class InputSimpleGenerics implements Comparable<InputSimpleGenerics>, Serializable
@ -27,6 +29,10 @@ class InputSimpleGenerics implements Comparable<InputSimpleGenerics>, Serializab
public static<T>Callable<T> callable2(Runnable task, T result)
{
Map<Class<?>, Integer> x = new HashMap<Class<?>, Integer>();
for (final Map.Entry<Class<?>, Integer> entry : x.entrySet()) {
entry.getValue();
}
return null;
}
}

View File

@ -2,6 +2,8 @@ package com.puppycrawl.tools.checkstyle.checks.whitespace;
import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import java.util.HashMap;
import java.util.Map;
public class GenericWhitespaceCheckTest
extends BaseCheckTestCase
@ -12,33 +14,38 @@ public class GenericWhitespaceCheckTest
public void setUp()
{
mCheckConfig = createCheckConfig(GenericWhitespaceCheck.class);
Map<Class<?>, Integer> x = new HashMap<Class<?>, Integer>();
for (final Map.Entry<Class<?>, Integer> entry : x.entrySet()) {
entry.getValue();
}
//for (final Entry<Class<?>, Integer> entry : entrySet())
}
public void testDefault() throws Exception
{
final String[] expected = {
"14:13: '<' is preceded with whitespace.",
"14:15: '<' is followed by whitespace.",
"14:23: '>' is preceded with whitespace.",
"14:43: '<' is preceded with whitespace.",
"14:45: '<' is followed by whitespace.",
"14:53: '>' is preceded with whitespace.",
"15:13: '<' is preceded with whitespace.",
"15:15: '<' is followed by whitespace.",
"15:20: '<' is preceded with whitespace.",
"15:22: '<' is followed by whitespace.",
"15:30: '>' is preceded with whitespace.",
"15:32: '>' is followed by whitespace.",
"15:32: '>' is preceded with whitespace.",
"15:52: '<' is preceded with whitespace.",
"15:54: '<' is followed by whitespace.",
"15:59: '<' is preceded with whitespace.",
"15:61: '<' is followed by whitespace.",
"15:69: '>' is preceded with whitespace.",
"15:71: '>' is followed by whitespace.",
"15:71: '>' is preceded with whitespace.",
"28:17: '<' is not preceded with whitespace.",
"28:21: '>' is followed by an illegal character.",
"16:13: '<' is preceded with whitespace.",
"16:15: '<' is followed by whitespace.",
"16:23: '>' is preceded with whitespace.",
"16:43: '<' is preceded with whitespace.",
"16:45: '<' is followed by whitespace.",
"16:53: '>' is preceded with whitespace.",
"17:13: '<' is preceded with whitespace.",
"17:15: '<' is followed by whitespace.",
"17:20: '<' is preceded with whitespace.",
"17:22: '<' is followed by whitespace.",
"17:30: '>' is preceded with whitespace.",
"17:32: '>' is followed by whitespace.",
"17:32: '>' is preceded with whitespace.",
"17:52: '<' is preceded with whitespace.",
"17:54: '<' is followed by whitespace.",
"17:59: '<' is preceded with whitespace.",
"17:61: '<' is followed by whitespace.",
"17:69: '>' is preceded with whitespace.",
"17:71: '>' is followed by whitespace.",
"17:71: '>' is preceded with whitespace.",
"30:17: '<' is not preceded with whitespace.",
"30:21: '>' is followed by an illegal character.",
};
verify(mCheckConfig,
getPath("whitespace/InputGenericWhitespaceCheck.java"),