diff options
author | Tor Norbye <tnorbye@google.com> | 2014-07-25 20:12:40 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-07-24 20:55:36 +0000 |
commit | 6044be7330c93bc8dacb0f63e62da8029f39a16f (patch) | |
tree | 0ba72f5de1949e0527874a799baa224cbe1537e0 /python/src/com/jetbrains/python/psi/impl/PyStarImportElementImpl.java | |
parent | b03a5855292feb8c331815f883fe64372aacd872 (diff) | |
parent | e5266e2343c8d275d79fa0be725180d0fe3a993c (diff) | |
download | idea-6044be7330c93bc8dacb0f63e62da8029f39a16f.tar.gz |
Merge "Merge remote-tracking branch 'aosp/upstream-master' into merge"
Diffstat (limited to 'python/src/com/jetbrains/python/psi/impl/PyStarImportElementImpl.java')
-rw-r--r-- | python/src/com/jetbrains/python/psi/impl/PyStarImportElementImpl.java | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/python/src/com/jetbrains/python/psi/impl/PyStarImportElementImpl.java b/python/src/com/jetbrains/python/psi/impl/PyStarImportElementImpl.java index 307ac8e22841..4011c233e38d 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyStarImportElementImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyStarImportElementImpl.java @@ -15,6 +15,8 @@ */ package com.jetbrains.python.psi.impl; +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; import com.intellij.lang.ASTNode; import com.intellij.navigation.ItemPresentation; import com.intellij.psi.PsiElement; @@ -50,7 +52,11 @@ 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) { - chain.add(((PyFile) source).iterateNames()); + Iterable<PyElement> declaredNames = ((PyFile)source).iterateNames(); + if (((PyFile)source).getDunderAll() == null) { + declaredNames = excludeUnderscoredNames(declaredNames); + } + chain.add(declaredNames); } } return chain; @@ -58,6 +64,19 @@ public class PyStarImportElementImpl extends PyElementImpl implements PyStarImpo return Collections.emptyList(); } + private static Iterable<PyElement> excludeUnderscoredNames(Iterable<PyElement> declaredNames) { + 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; + } + }); + } + @Nullable public PsiElement getElementNamed(final String name) { if (PyUtil.isClassPrivateName(name)) { @@ -76,7 +95,7 @@ public class PyStarImportElementImpl extends PyElementImpl implements PyStarImpo 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)) { + if (all != null ? !all.contains(name) : name.startsWith("_")) { continue; } return result; |