diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheck.java index d87250661..37fae179c 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheck.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheck.java @@ -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", ">"); } } diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/whitespace/InputGenericWhitespaceCheck.java b/src/testinputs/com/puppycrawl/tools/checkstyle/whitespace/InputGenericWhitespaceCheck.java index a667372b4..3f633de5c 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/whitespace/InputGenericWhitespaceCheck.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/whitespace/InputGenericWhitespaceCheck.java @@ -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, Serializable @@ -27,6 +29,10 @@ class InputSimpleGenerics implements Comparable, Serializab public staticCallable callable2(Runnable task, T result) { + Map, Integer> x = new HashMap, Integer>(); + for (final Map.Entry, Integer> entry : x.entrySet()) { + entry.getValue(); + } return null; } } diff --git a/src/tests/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheckTest.java b/src/tests/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheckTest.java index 0a117cd98..d1f4a54a3 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheckTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheckTest.java @@ -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, Integer> x = new HashMap, Integer>(); + for (final Map.Entry, Integer> entry : x.entrySet()) { + entry.getValue(); + } + //for (final Entry, 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"),