diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java index 6c815655fe22..a9459f33774f 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.util.gotoByName; @@ -54,6 +54,7 @@ import javax.accessibility.AccessibleContext; import javax.swing.*; import javax.swing.border.Border; import java.awt.*; +import java.lang.ref.WeakReference; import java.util.List; import java.util.*; import java.util.regex.Matcher; @@ -71,7 +72,7 @@ public class GotoActionModel implements ChooseByNameModel, Comparator, D @Nullable private final Project myProject; private final Component myContextComponent; - @Nullable private final Editor myEditor; + @Nullable private final WeakReference myEditor; protected final ActionManager myActionManager = ActionManager.getInstance(); @@ -100,7 +101,7 @@ public class GotoActionModel implements ChooseByNameModel, Comparator, D public GotoActionModel(@Nullable Project project, Component component, @Nullable Editor editor, @Nullable ModalityState modalityState) { myProject = project; myContextComponent = component; - myEditor = editor; + myEditor = new WeakReference<>(editor); myModality = modalityState; buildActions(); } @@ -120,10 +121,11 @@ public class GotoActionModel implements ChooseByNameModel, Comparator, D @NotNull Map getAvailableIntentions() { Map map = new TreeMap<>(); + Editor editor = myEditor != null ? myEditor.get() : null; if (myProject != null && !myProject.isDisposed() && !DumbService.isDumb(myProject) && - myEditor != null && !myEditor.isDisposed()) { - PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(myEditor.getDocument()); - ApplyIntentionAction[] children = file == null ? null : ApplyIntentionAction.getAvailableIntentions(myEditor, file); + editor != null && !editor.isDisposed()) { + PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument()); + ApplyIntentionAction[] children = file == null ? null : ApplyIntentionAction.getAvailableIntentions(editor, file); if (children != null) { for (ApplyIntentionAction action : children) { map.put(action.getName(), action);