mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-223086 ImportClassFixBase.fixSilently affects performance even if UnambiguousImportsOnTheFly settings is disabled
GitOrigin-RevId: 93ada9904a45a1dfc497678e5f79c87c9245bde9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
19fae49872
commit
91c04c991f
+15
-8
@@ -298,7 +298,8 @@ public abstract class ImportClassFixBase<T extends PsiElement, R extends PsiRefe
|
||||
|
||||
@Override
|
||||
public boolean fixSilently(@NotNull Editor editor) {
|
||||
return doFix(editor, false, false) == Result.CLASS_AUTO_IMPORTED;
|
||||
return mayAutoImportNow(editor, myElement.getContainingFile()) &&
|
||||
doFix(editor, false, false) == Result.CLASS_AUTO_IMPORTED;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -334,15 +335,9 @@ public abstract class ImportClassFixBase<T extends PsiElement, R extends PsiRefe
|
||||
|
||||
boolean canImportHere = true;
|
||||
|
||||
boolean isInModelessContext = Registry.is("ide.perProjectModality") ?
|
||||
!LaterInvocator.isInModalContextForProject(editor.getProject()) :
|
||||
!LaterInvocator.isInModalContext();
|
||||
|
||||
if (classes.length == 1 &&
|
||||
(canImportHere = canImportHere(allowCaretNearRef, editor, psiFile, classes[0].getName())) &&
|
||||
isAddUnambiguousImportsOnTheFlyEnabled(psiFile) &&
|
||||
(ApplicationManager.getApplication().isUnitTestMode() || DaemonListeners.canChangeFileSilently(psiFile)) &&
|
||||
isInModelessContext &&
|
||||
mayAutoImportNow(editor, psiFile) &&
|
||||
!autoImportWillInsertUnexpectedCharacters(classes[0])) {
|
||||
CommandProcessor.getInstance().runUndoTransparentAction(() -> action.execute());
|
||||
return Result.CLASS_AUTO_IMPORTED;
|
||||
@@ -359,6 +354,18 @@ public abstract class ImportClassFixBase<T extends PsiElement, R extends PsiRefe
|
||||
return Result.POPUP_NOT_SHOWN;
|
||||
}
|
||||
|
||||
private static boolean mayAutoImportNow(@NotNull Editor editor, @NotNull PsiFile psiFile) {
|
||||
return isAddUnambiguousImportsOnTheFlyEnabled(psiFile) &&
|
||||
(ApplicationManager.getApplication().isUnitTestMode() || DaemonListeners.canChangeFileSilently(psiFile)) &&
|
||||
isInModelessContext(editor);
|
||||
}
|
||||
|
||||
private static boolean isInModelessContext(@NotNull Editor editor) {
|
||||
return Registry.is("ide.perProjectModality") ?
|
||||
!LaterInvocator.isInModalContextForProject(editor.getProject()) :
|
||||
!LaterInvocator.isInModalContext();
|
||||
}
|
||||
|
||||
public static boolean isAddUnambiguousImportsOnTheFlyEnabled(@NotNull PsiFile psiFile) {
|
||||
return FileTypeUtils.isInServerPageFile(psiFile) ?
|
||||
CodeInsightSettings.getInstance().JSP_ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY :
|
||||
|
||||
Reference in New Issue
Block a user