Skip to content

Commit

Permalink
Fix package-info.java identification on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan202 committed Jun 21, 2021
1 parent 57e8af7 commit 5af2b42
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Expand Up @@ -24,6 +24,7 @@
import com.google.errorprone.bugpatterns.BugChecker.CompilationUnitTreeMatcher;
import com.google.errorprone.matchers.Description;
import com.sun.source.tree.CompilationUnitTree;
import java.io.File;

/** A {@link BugChecker}; see the associated {@link BugPattern} annotation for details. */
@BugPattern(
Expand All @@ -37,7 +38,7 @@ public Description matchCompilationUnit(CompilationUnitTree tree, VisitorState s
return NO_MATCH;
}
String name = tree.getSourceFile().getName();
int idx = name.lastIndexOf('/');
int idx = name.lastIndexOf(File.separatorChar);
if (idx != -1) {
name = name.substring(idx + 1);
}
Expand Down
Expand Up @@ -44,6 +44,7 @@
import com.sun.tools.javac.code.Symbol.PackageSymbol;
import com.sun.tools.javac.code.Symbol.TypeSymbol;
import com.sun.tools.javac.util.Position;
import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -189,7 +190,7 @@ public Void visitIdentifier(IdentifierTree identifierTree, Void aVoid) {

private static boolean isPackageInfo(CompilationUnitTree tree) {
String name = tree.getSourceFile().getName();
int idx = name.lastIndexOf('/');
int idx = name.lastIndexOf(File.separatorChar);
if (idx != -1) {
name = name.substring(idx + 1);
}
Expand Down

0 comments on commit 5af2b42

Please sign in to comment.