Skip to content

Commit

Permalink
Issue checkstyle#3752: Added tokens to SeparatorWrapCheck in google s…
Browse files Browse the repository at this point in the history
…tyle
  • Loading branch information
kazachka committed Jul 4, 2017
1 parent ab10e1a commit 95c09a2
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 4 deletions.
12 changes: 12 additions & 0 deletions src/main/resources/google_checks.xml
Expand Up @@ -93,6 +93,18 @@
<property name="tokens" value="COMMA"/>
<property name="option" value="EOL"/>
</module>
<module name="SeparatorWrap">
<!-- ELLIPSIS is EOL until https://github.com/google/styleguide/issues/258 -->
<property name="id" value="SeparatorWrapEllipsis"/>
<property name="tokens" value="ELLIPSIS"/>
<property name="option" value="EOL"/>
</module>
<module name="SeparatorWrap">
<!-- ARRAY_DECLARATOR is EOL until https://github.com/google/styleguide/issues/259 -->
<property name="id" value="SeparatorWrapArrayDeclarator"/>
<property name="tokens" value="ARRAY_DECLARATOR"/>
<property name="option" value="EOL"/>
</module>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapMethodRef"/>
<property name="tokens" value="METHOD_REF"/>
Expand Down
Expand Up @@ -112,4 +112,25 @@ public void testInvalidOption() throws Exception {
ex.getMessage().startsWith(messageStart));
}
}

@Test
public void testEllipsis() throws Exception {
checkConfig.addAttribute("option", "EOL");
checkConfig.addAttribute("tokens", "ELLIPSIS");
final String[] expected = {
"11:13: " + getCheckMessage(MSG_LINE_PREVIOUS, "..."),
};
verify(checkConfig, getPath("InputSeparatorWrapForEllipsis.java"), expected);
}

@Test
public void testArrayDeclarator() throws Exception {
checkConfig.addAttribute("option", "EOL");
checkConfig.addAttribute("tokens", "ARRAY_DECLARATOR");
final String[] expected = {
"9:13: " + getCheckMessage(MSG_LINE_PREVIOUS, "["),
};
verify(checkConfig, getPath("InputSeparatorWrapForArrayDeclarator.java"), expected);
}

}
Expand Up @@ -178,10 +178,7 @@ public class AllChecksTest extends BaseCheckTestSupport {
// be not strict there
"METHOD_DEF", "CTOR_DEF", "CLASS_DEF", "ENUM_DEF", "INTERFACE_DEF")
.collect(Collectors.toSet()));
GOOGLE_TOKENS_IN_CONFIG_TO_IGNORE.put("SeparatorWrap", Stream.of(
// state of configuration until
// https://github.com/checkstyle/checkstyle/issues/3752
"RBRACK", "AT", "ELLIPSIS", "SEMI", "ARRAY_DECLARATOR",
GOOGLE_TOKENS_IN_CONFIG_TO_IGNORE.put("SeparatorWrap", Stream.of("RBRACK", "AT", "SEMI",
// needs context to decide what type of parentheses should be separated or not
// which this check does not provide
"LPAREN", "RPAREN").collect(Collectors.toSet()));
Expand Down
@@ -0,0 +1,13 @@
package com.puppycrawl.tools.checkstyle.checks.whitespace.separatorwrap;

class InputSeparatorWrapTestArrayDeclarator {

protected int[] arrayDeclarationWithGoodWrapping = new int[
] {1, 2};

protected int[] arrayDeclarationWithBadWrapping = new int
[] {1, 2};

}


@@ -0,0 +1,16 @@
package com.puppycrawl.tools.checkstyle.checks.whitespace.separatorwrap;

class InputSeparatorWrapTestEllipsis {

public void testMethodWithGoodWrapping(String...
parameters) {

}

public void testMethodWithBadWrapping(String
...parameters) {

}

}

0 comments on commit 95c09a2

Please sign in to comment.