Skip to content

Commit

Permalink
Issue #14084: fix Checker violation for nonnegative integer argument
Browse files Browse the repository at this point in the history
  • Loading branch information
Lmh-java committed Mar 17, 2024
1 parent 2126aa1 commit 7fa2268
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@
</details>
</checkerFrameworkError>

<checkerFrameworkError unstable="false">
<fileName>src/main/java/com/puppycrawl/tools/checkstyle/DetailAstImpl.java</fileName>
<specifier>argument</specifier>
<message>incompatible argument for parameter bitIndex of BitSet.get.</message>
<lineContent>return getBranchTokenTypes().get(tokenType);</lineContent>
<details>
found : int
required: @NonNegative int
</details>
</checkerFrameworkError>

<checkerFrameworkError unstable="false">
<fileName>src/main/java/com/puppycrawl/tools/checkstyle/DetailAstImpl.java</fileName>
<specifier>argument</specifier>
Expand Down
1 change: 1 addition & 0 deletions config/import-control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<allow pkg="javax.xml.parsers"/>
<allow pkg="org.apache.commons.beanutils"/>
<allow pkg="org.apache.commons.logging"/>
<allow class="org.checkerframework.checker.index.qual.NonNegative"/>
<allow pkg="org.xml.sax"/>

<!-- The local ones -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.List;

import org.antlr.v4.runtime.Token;
import org.checkerframework.checker.index.qual.NonNegative;

import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.utils.TokenUtil;
Expand Down Expand Up @@ -383,7 +384,7 @@ private BitSet getBranchTokenTypes() {
}

@Override
public boolean branchContains(int tokenType) {
public boolean branchContains(@NonNegative int tokenType) {
return getBranchTokenTypes().get(tokenType);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

package com.puppycrawl.tools.checkstyle.api;

import org.checkerframework.checker.index.qual.NonNegative;

/**
* An interface of Checkstyle's AST nodes for traversing trees generated from the
* Java code. The main purpose of this interface is to abstract away ANTLR
Expand Down Expand Up @@ -105,7 +107,7 @@ public interface DetailAST {
* for more details.
*/
@Deprecated(since = "8.43")
boolean branchContains(int type);
boolean branchContains(@NonNegative int type);

/**
* Returns the previous sibling or null if no such sibling exists.
Expand Down

0 comments on commit 7fa2268

Please sign in to comment.