mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -8,6 +8,8 @@ import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiFileSystemItem;
|
||||
@@ -170,4 +172,15 @@ public class AutoImportQuickFix implements LocalQuickFix, HighPriorityAction {
|
||||
final String text = myReference.getElement().getText();
|
||||
return myReference.getRangeInElement().substring(text); // text of the part we're working with
|
||||
}
|
||||
|
||||
public boolean hasProjectImports() {
|
||||
ProjectFileIndex fileIndex = ProjectFileIndex.SERVICE.getInstance(myNode.getProject());
|
||||
for (ImportCandidateHolder anImport : myImports) {
|
||||
VirtualFile file = anImport.getFile().getVirtualFile();
|
||||
if (file != null && fileIndex.isInContent(file)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.FilenameIndex;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
@@ -110,7 +111,7 @@ public class PythonReferenceImporter implements ReferenceImporter {
|
||||
Set<String> seenFileNames = new HashSet<String>(); // true import names
|
||||
|
||||
PsiFile existingImportFile = addCandidatesFromExistingImports(node, refText, fix, seenFileNames);
|
||||
if (fix.getCandidatesCount() == 0) {
|
||||
if (fix.getCandidatesCount() == 0 || fix.hasProjectImports() || Registry.is("python.import.always.ask")) {
|
||||
// maybe some unimported file has it, too
|
||||
ProgressManager.checkCanceled(); // before expensive index searches
|
||||
addSymbolImportCandidates(node, refText, fix, seenFileNames, existingImportFile);
|
||||
|
||||
Reference in New Issue
Block a user