Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the workaround for SimpleCharStream. #3143

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -18,6 +18,7 @@

import static com.google.errorprone.BugPattern.SeverityLevel.SUGGESTION;
import static com.google.errorprone.matchers.Description.NO_MATCH;
import static com.google.errorprone.util.ASTHelpers.enclosingClass;
import static com.google.errorprone.util.ASTHelpers.getSymbol;

import com.google.common.base.CharMatcher;
Expand Down Expand Up @@ -74,7 +75,8 @@ private Description checkArrayDimensions(Tree tree, Tree type, VisitorState stat
if (idx > nonWhitespace) {
String replacement = dim.substring(idx) + dim.substring(0, idx);
// SimpleCharStream generates violations in other packages, and is challenging to fix.
if (getSymbol(tree).owner.name.contentEquals("SimpleCharStream")) {
var enclosingClass = enclosingClass(getSymbol(tree));
if (enclosingClass != null && enclosingClass.name.contentEquals("SimpleCharStream")) {
return NO_MATCH;
}
return describeMatch(tree, SuggestedFix.replace(start, end, replacement));
Expand Down
Expand Up @@ -94,7 +94,9 @@ public void negativeInSimpleCharStream() {
.addSourceLines(
"SimpleCharStream.java", //
"final class SimpleCharStream {",
" int a[];",
" void test() {",
" int a[];",
" }",
"}")
.doTest();
}
Expand Down