do not resolve relative import as absolute if corresponding virtualFile is null
authorEkaterina Tuzova <Ekaterina.Tuzova@jetbrains.com>
Tue, 24 Feb 2015 16:21:29 +0000 (19:21 +0300)
committerEkaterina Tuzova <Ekaterina.Tuzova@jetbrains.com>
Tue, 24 Feb 2015 16:21:29 +0000 (19:21 +0300)
python/src/com/jetbrains/python/psi/resolve/ResolveImportUtil.java

index 2aa3b67ccef9ab7e0de26dc0f41931a2470f568f..068de2449cf8b554e1a99c64cbb0940802c8d865 100644 (file)
@@ -216,7 +216,9 @@ public class ResolveImportUtil {
   @NotNull
   private static List<PsiElement> resolveRelativeImportAsAbsolute(@NotNull PsiFile foothold,
                                                                   @NotNull QualifiedName qualifiedName) {
   @NotNull
   private static List<PsiElement> resolveRelativeImportAsAbsolute(@NotNull PsiFile foothold,
                                                                   @NotNull QualifiedName qualifiedName) {
-    final boolean inSource = FileIndexFacade.getInstance(foothold.getProject()).isInContent(foothold.getVirtualFile());
+    final VirtualFile virtualFile = foothold.getVirtualFile();
+    if (virtualFile == null) return Collections.emptyList();
+    final boolean inSource = FileIndexFacade.getInstance(foothold.getProject()).isInContent(virtualFile);
     if (inSource) return Collections.emptyList();
     final PsiDirectory containingDirectory = foothold.getContainingDirectory();
     if (containingDirectory != null) {
     if (inSource) return Collections.emptyList();
     final PsiDirectory containingDirectory = foothold.getContainingDirectory();
     if (containingDirectory != null) {