Skip to content

Commit

Permalink
Issue checkstyle#12145: corrected tokens so all are required
Browse files Browse the repository at this point in the history
  • Loading branch information
rnveach committed Aug 31, 2022
1 parent d87d034 commit f7d8ecc
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 38 deletions.
Expand Up @@ -128,14 +128,6 @@
* Type is {@code boolean}.
* Default value is {@code false}.
* </li>
* <li>
* Property {@code tokens} - tokens to check
* Type is {@code java.lang.String[]}.
* Validation type is {@code tokenSet}.
* Default value is:
* <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#STATIC_IMPORT">
* STATIC_IMPORT</a>.
* </li>
* </ul>
* <p>
* To configure the check:
Expand Down Expand Up @@ -773,17 +765,17 @@ public void setUseContainerOrderingForStatic(boolean useContainerOrdering) {

@Override
public int[] getDefaultTokens() {
return getAcceptableTokens();
return getRequiredTokens();
}

@Override
public int[] getAcceptableTokens() {
return new int[] {TokenTypes.IMPORT, TokenTypes.STATIC_IMPORT};
return getRequiredTokens();
}

@Override
public int[] getRequiredTokens() {
return new int[] {TokenTypes.IMPORT};
return new int[] {TokenTypes.IMPORT, TokenTypes.STATIC_IMPORT};
}

@Override
Expand Down
Expand Up @@ -91,12 +91,6 @@
<description>control whether to use container
ordering (Eclipse IDE term) for static imports or not.</description>
</property>
<property default-value="STATIC_IMPORT"
name="tokens"
type="java.lang.String[]"
validation-type="tokenSet">
<description>tokens to check</description>
</property>
</properties>
<message-keys>
<message-key key="import.groups.separated.internally"/>
Expand Down
Expand Up @@ -303,6 +303,8 @@ public void testGetGroupNumber() throws Exception {
@Test
public void testHonorsTokenProperty() throws Exception {
final String[] expected = {
"20:1: " + getCheckMessage(MSG_ORDERING, "java.awt.Button.ABORT"),
"21:1: " + getCheckMessage(MSG_ORDERING, "java.awt.Dialog"),
"22:1: " + getCheckMessage(MSG_ORDERING, "java.awt.Button"),
};

Expand Down
Expand Up @@ -17,8 +17,8 @@
package com.puppycrawl.tools.checkstyle.checks.imports.importorder;

import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE; // ok
import static java.awt.Button.ABORT; // ok
import java.awt.Dialog; // ok
import static java.awt.Button.ABORT; // violation
import java.awt.Dialog; // violation
import java.awt.Button; // violation

public class InputImportOrder_HonorsTokensProperty {
Expand Down
19 changes: 0 additions & 19 deletions src/xdocs/config_imports.xml
Expand Up @@ -1927,25 +1927,6 @@ import java.util.stream.IntStream;
<td><code>false</code></td>
<td>7.1</td>
</tr>

<tr>
<td>tokens</td>
<td>tokens to check</td>

<td>
subset of tokens
<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#STATIC_IMPORT">
STATIC_IMPORT</a>
.
</td>

<td>
<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#STATIC_IMPORT">
STATIC_IMPORT</a>
.
</td>
<td>3.2</td>
</tr>
</table>
</div>
</subsection>
Expand Down

0 comments on commit f7d8ecc

Please sign in to comment.