PY-18970 Check that imports in "project" group don't belong to any library root
[idea/community.git] / python / src / com / jetbrains / python / codeInsight / imports / AddImportHelper.java
index 1f5bbbe3511deac9c8d041061b0bf5c701f1de9b..8534a2c900aabd6d4ca1c4018052d4f9acb61c06 100644 (file)
@@ -20,6 +20,7 @@ import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.module.ModuleUtilCore;
 import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.openapi.roots.ProjectFileIndex;
 import com.intellij.openapi.roots.ProjectRootManager;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.VirtualFile;
@@ -263,7 +264,8 @@ public class AddImportHelper {
       return UNRESOLVED_SYMBOL_PRIORITY;
     }
     final ProjectRootManager projectRootManager = ProjectRootManager.getInstance(toImport.getProject());
-    if (projectRootManager.getFileIndex().isInContent(vFile)) {
+    final ProjectFileIndex fileIndex = projectRootManager.getFileIndex();
+    if (fileIndex.isInContent(vFile) && !fileIndex.isInLibraryClasses(vFile)) {
       return ImportPriority.PROJECT;
     }
     final Module module = ModuleUtilCore.findModuleForPsiElement(importLocation);