Refactored isPackage() checks

This commit is contained in:
Andrey Vlasovskikh
2012-04-30 20:09:29 +04:00
parent c83bca1889
commit ff7c083a42
2 changed files with 12 additions and 5 deletions
@@ -628,6 +628,17 @@ public class PyUtil {
return target;
}
public static boolean isPackage(@NotNull PsiDirectory directory) {
if (turnDirIntoInit(directory) != null) {
return true;
}
return hasNamespacePackageFile(directory);
}
public static boolean isPackage(@NotNull PsiFile file) {
return turnInitIntoDir(file) != null;
}
/**
* Counts initial underscores of an identifier.
*
@@ -61,7 +61,7 @@ public class PyModuleType implements PyType { // Modules don't descend from obje
if (attribute != null) {
return ResolveResultList.to(attribute);
}
if (location != null && isPackage(myModule)) {
if (location != null && PyUtil.isPackage(myModule)) {
return resolveImplicitPackageMember(name, location);
}
return null;
@@ -128,10 +128,6 @@ public class PyModuleType implements PyType { // Modules don't descend from obje
return visibleImports;
}
private static boolean isPackage(@NotNull PyFile file) {
return PyUtil.turnInitIntoDir(file) != null;
}
/**
* @param directory the module directory
*