File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
check_api/src/main/java/com/google/errorprone/util Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -1160,15 +1160,22 @@ public static ClassSymbol enclosingClass(Symbol sym) {
1160
1160
}
1161
1161
1162
1162
/** Return the enclosing {@code PackageSymbol} of the given symbol, or {@code null}. */
1163
+ @ Nullable
1163
1164
public static PackageSymbol enclosingPackage (Symbol sym ) {
1164
- return sym .packge ();
1165
+ Symbol curr = sym ;
1166
+ for (; curr != null && curr .owner != null ; curr = curr .owner ) {
1167
+ if (curr .getKind ().equals (ElementKind .PACKAGE )) {
1168
+ return (PackageSymbol ) curr ;
1169
+ }
1170
+ }
1171
+ return null ;
1165
1172
}
1166
1173
1167
1174
/** Return true if the given symbol is defined in the current package. */
1168
1175
public static boolean inSamePackage (Symbol targetSymbol , VisitorState state ) {
1169
1176
JCCompilationUnit compilationUnit = (JCCompilationUnit ) state .getPath ().getCompilationUnit ();
1170
1177
PackageSymbol usePackage = compilationUnit .packge ;
1171
- PackageSymbol targetPackage = targetSymbol . packge ( );
1178
+ PackageSymbol targetPackage = enclosingPackage ( targetSymbol );
1172
1179
1173
1180
return targetPackage != null
1174
1181
&& usePackage != null
You can’t perform that action at this time.
0 commit comments