This commit is contained in:
Dmitry Jemerov
2012-08-15 13:39:53 +02:00
parent 79a71c19f5
commit 3c6c502520
2 changed files with 8 additions and 0 deletions
@@ -2,6 +2,7 @@ package com.jetbrains.python.psi;
import com.intellij.psi.PsiFile;
import com.jetbrains.python.codeInsight.controlflow.ScopeOwner;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
@@ -28,6 +29,12 @@ public interface PyFile extends PyElement, PsiFile, PyDocStringOwner, ScopeOwner
List<PyFromImportStatement> getFromImports();
/**
* Returns the list of import elements in all 'import xxx' statements within the file.
*
* @return the list of import targets.
*/
@NotNull
List<PyImportElement> getImportTargets();
/**
@@ -513,6 +513,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
return false;
}
@NotNull
public List<PyImportElement> getImportTargets() {
List<PyImportElement> ret = new ArrayList<PyImportElement>();
List<PyImportStatement> imports = PyPsiUtils.collectStubChildren(this, this.getStub(), PyElementTypes.IMPORT_STATEMENT, PyImportStatement.class);