From f8fdb0e10f7a683cb76635c2e5c04f8cc83746fb Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 21 Aug 2012 17:04:30 +0200 Subject: [PATCH] EA-38373 - NPE: PythonReferenceImporter.addImportViaElement --- .../python/codeInsight/imports/PythonReferenceImporter.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/src/com/jetbrains/python/codeInsight/imports/PythonReferenceImporter.java b/python/src/com/jetbrains/python/codeInsight/imports/PythonReferenceImporter.java index 8baf23991d82..1bd3a88d43f7 100644 --- a/python/src/com/jetbrains/python/codeInsight/imports/PythonReferenceImporter.java +++ b/python/src/com/jetbrains/python/codeInsight/imports/PythonReferenceImporter.java @@ -166,7 +166,10 @@ public class PythonReferenceImporter implements ReferenceImporter { PsiElement source) { PsiElement sourceFile = PyUtil.turnDirIntoInit(source); if (sourceFile instanceof PyFileImpl) { - seenFileNames.add(importElement.getImportReferenceExpression().getReferencedName()); + PyReferenceExpression importReferenceExpression = importElement.getImportReferenceExpression(); + if (importReferenceExpression != null) { + seenFileNames.add(importReferenceExpression.getReferencedName()); + } PyFileImpl importSourceFile = (PyFileImpl)sourceFile; PsiElement res = importSourceFile.findExportedName(refText); // allow importing from this source if it either declares the name itself or represents a higher-level package that reexports the name