summaryrefslogtreecommitdiff
path: root/python/src/com/jetbrains/python/psi/impl/PyStarImportElementImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'python/src/com/jetbrains/python/psi/impl/PyStarImportElementImpl.java')
-rw-r--r--python/src/com/jetbrains/python/psi/impl/PyStarImportElementImpl.java21
1 files changed, 6 insertions, 15 deletions
diff --git a/python/src/com/jetbrains/python/psi/impl/PyStarImportElementImpl.java b/python/src/com/jetbrains/python/psi/impl/PyStarImportElementImpl.java
index 4011c233e38d..88c3134481a8 100644
--- a/python/src/com/jetbrains/python/psi/impl/PyStarImportElementImpl.java
+++ b/python/src/com/jetbrains/python/psi/impl/PyStarImportElementImpl.java
@@ -52,11 +52,8 @@ public class PyStarImportElementImpl extends PyElementImpl implements PyStarImpo
for (PsiElement importedFile : new HashSet<PsiElement>(importedFiles)) { // resolver gives lots of duplicates
final PsiElement source = PyUtil.turnDirIntoInit(importedFile);
if (source instanceof PyFile) {
- Iterable<PyElement> declaredNames = ((PyFile)source).iterateNames();
- if (((PyFile)source).getDunderAll() == null) {
- declaredNames = excludeUnderscoredNames(declaredNames);
- }
- chain.add(declaredNames);
+ final PyFile sourceFile = (PyFile)source;
+ chain.add(filterStarImportableNames(sourceFile.iterateNames(), sourceFile));
}
}
return chain;
@@ -64,15 +61,13 @@ public class PyStarImportElementImpl extends PyElementImpl implements PyStarImpo
return Collections.emptyList();
}
- private static Iterable<PyElement> excludeUnderscoredNames(Iterable<PyElement> declaredNames) {
+ @NotNull
+ private static Iterable<PyElement> filterStarImportableNames(@NotNull Iterable<PyElement> declaredNames, @NotNull final PyFile file) {
return Iterables.filter(declaredNames, new Predicate<PyElement>() {
@Override
public boolean apply(@Nullable PyElement input) {
final String name = input != null ? input.getName() : null;
- if (name != null && name.startsWith("_")) {
- return false;
- }
- return true;
+ return name != null && PyUtil.isStarImportableFrom(name, file);
}
});
}
@@ -93,11 +88,7 @@ public class PyStarImportElementImpl extends PyElementImpl implements PyStarImpo
final List<? extends RatedResolveResult> results = moduleType.resolveMember(name, null, AccessDirection.READ,
PyResolveContext.defaultContext());
final PsiElement result = results != null && !results.isEmpty() ? results.get(0).getElement() : null;
- if (result != null) {
- final List<String> all = sourceFile.getDunderAll();
- if (all != null ? !all.contains(name) : name.startsWith("_")) {
- continue;
- }
+ if (result != null && PyUtil.isStarImportableFrom(name, sourceFile) ) {
return result;
}
}