mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
optimization: hoist "may import" condition out of loop
GitOrigin-RevId: f63f50eed1ba065fb8449b68e80e39c35e63c810
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e01cab210c
commit
93da6311fc
+10
-10
@@ -54,7 +54,7 @@ public class ShowAutoImportPass extends TextEditorHighlightingPass {
|
||||
private final int myEndOffset;
|
||||
private final boolean hasDirtyTextRange;
|
||||
|
||||
ShowAutoImportPass(@NotNull Project project, @NotNull final PsiFile file, @NotNull Editor editor) {
|
||||
ShowAutoImportPass(@NotNull Project project, @NotNull PsiFile file, @NotNull Editor editor) {
|
||||
super(project, editor.getDocument(), false);
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
|
||||
@@ -105,9 +105,10 @@ public class ShowAutoImportPass extends TextEditorHighlightingPass {
|
||||
}
|
||||
}
|
||||
|
||||
private void importUnambiguousImports(final int caretOffset) {
|
||||
private void importUnambiguousImports(int caretOffset) {
|
||||
if (!mayAutoImportNow(myFile)) return;
|
||||
Document document = myEditor.getDocument();
|
||||
final List<HighlightInfo> infos = new ArrayList<>();
|
||||
List<HighlightInfo> infos = new ArrayList<>();
|
||||
DaemonCodeAnalyzerEx.processHighlights(document, myProject, null, 0, document.getTextLength(), info -> {
|
||||
if (info.hasHint() && info.getSeverity() == HighlightSeverity.ERROR && !info.getFixTextRange().containsOffset(caretOffset)) {
|
||||
infos.add(info);
|
||||
@@ -117,8 +118,7 @@ public class ShowAutoImportPass extends TextEditorHighlightingPass {
|
||||
|
||||
for (HighlightInfo info : infos) {
|
||||
for (HintAction action : extractHints(info)) {
|
||||
if (mayAutoImportNow(myFile) &&
|
||||
action.isAvailable(myProject, myEditor, myFile) &&
|
||||
if (action.isAvailable(myProject, myEditor, myFile) &&
|
||||
action.fixSilently(myEditor)) {
|
||||
break;
|
||||
}
|
||||
@@ -145,12 +145,12 @@ public class ShowAutoImportPass extends TextEditorHighlightingPass {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<HighlightInfo> getVisibleHighlights(final int startOffset,
|
||||
final int endOffset,
|
||||
private static List<HighlightInfo> getVisibleHighlights(int startOffset,
|
||||
int endOffset,
|
||||
@NotNull Project project,
|
||||
@NotNull Editor editor,
|
||||
boolean isDirty) {
|
||||
final List<HighlightInfo> highlights = new ArrayList<>();
|
||||
List<HighlightInfo> highlights = new ArrayList<>();
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
DaemonCodeAnalyzerEx.processHighlights(editor.getDocument(), project, null, startOffset, endOffset, info -> {
|
||||
//no changes after escape => suggest imports under caret only
|
||||
@@ -273,8 +273,8 @@ public class ShowAutoImportPass extends TextEditorHighlightingPass {
|
||||
|
||||
|
||||
@NotNull
|
||||
public static @NlsContexts.HintText String getMessage(final boolean multiple, @NotNull String name) {
|
||||
final String messageKey = multiple ? "import.popup.multiple" : "import.popup.text";
|
||||
public static @NlsContexts.HintText String getMessage(boolean multiple, @NotNull String name) {
|
||||
String messageKey = multiple ? "import.popup.multiple" : "import.popup.text";
|
||||
String hintText = DaemonBundle.message(messageKey, name);
|
||||
hintText +=
|
||||
" " + KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_SHOW_INTENTION_ACTIONS));
|
||||
|
||||
Reference in New Issue
Block a user