mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
explicit cancel of searching for implementations if popup closed (IDEA-158010)
This commit is contained in:
+3
@@ -144,6 +144,9 @@ public class PsiElementListNavigator {
|
||||
}).
|
||||
setCancelCallback(() -> {
|
||||
HintUpdateSupply.hideHint(list);
|
||||
if (listUpdaterTask != null) {
|
||||
return listUpdaterTask.cancelTask();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
final Ref<UsageView> usageView = new Ref<UsageView>();
|
||||
|
||||
+7
-16
@@ -300,7 +300,9 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
|
||||
})
|
||||
.setCancelCallback(() -> {
|
||||
ImplementationsUpdaterTask task = SoftReference.dereference(myTaskRef);
|
||||
cancelTask(task);
|
||||
if (task != null) {
|
||||
task.cancelTask();
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
})
|
||||
.createPopup();
|
||||
@@ -314,17 +316,6 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean cancelTask(@Nullable ImplementationsUpdaterTask task) {
|
||||
if (task != null) {
|
||||
ProgressIndicator indicator = task.myIndicator;
|
||||
if (indicator != null) {
|
||||
indicator.cancel();
|
||||
}
|
||||
return task.setCanceled();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void updateInBackground(Editor editor,
|
||||
@Nullable PsiElement element,
|
||||
@NotNull ImplementationViewComponent component,
|
||||
@@ -332,7 +323,9 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
|
||||
@NotNull AbstractPopup popup,
|
||||
@NotNull Ref<UsageView> usageView) {
|
||||
final ImplementationsUpdaterTask updaterTask = SoftReference.dereference(myTaskRef);
|
||||
cancelTask(updaterTask);
|
||||
if (updaterTask != null) {
|
||||
updaterTask.cancelTask();
|
||||
}
|
||||
|
||||
if (element == null) return; //already found
|
||||
final ImplementationsUpdaterTask task = new ImplementationsUpdaterTask(element, editor, title, isIncludeAlwaysSelf());
|
||||
@@ -412,7 +405,6 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
|
||||
private final PsiElement myElement;
|
||||
private final boolean myIncludeSelf;
|
||||
private PsiElement[] myElements;
|
||||
private volatile ProgressIndicator myIndicator;
|
||||
|
||||
private ImplementationsUpdaterTask(@NotNull PsiElement element, final Editor editor, final String caption, boolean includeSelf) {
|
||||
super(element.getProject(), ImplementationSearcher.SEARCHING_FOR_IMPLEMENTATIONS);
|
||||
@@ -445,7 +437,6 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
|
||||
|
||||
@Override
|
||||
public void run(@NotNull final ProgressIndicator indicator) {
|
||||
myIndicator = indicator;
|
||||
super.run(indicator);
|
||||
final ImplementationSearcher.BackgroundableImplementationSearcher implementationSearcher =
|
||||
new ImplementationSearcher.BackgroundableImplementationSearcher() {
|
||||
@@ -477,7 +468,7 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
if (!cancelTask(this)) {
|
||||
if (!cancelTask()) {
|
||||
myComponent.update(myElements, myComponent.getIndex());
|
||||
}
|
||||
super.onSuccess();
|
||||
|
||||
@@ -52,6 +52,7 @@ public abstract class BackgroundUpdaterTask<T> extends Task.Backgroundable {
|
||||
|
||||
private volatile boolean myCanceled;
|
||||
private volatile boolean myFinished;
|
||||
private volatile ProgressIndicator myIndicator;
|
||||
|
||||
public BackgroundUpdaterTask(Project project, String title, boolean canBeCancelled) {
|
||||
super(project, title, canBeCancelled);
|
||||
@@ -132,6 +133,7 @@ public abstract class BackgroundUpdaterTask<T> extends Task.Backgroundable {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
paintBusy(true);
|
||||
myIndicator = indicator;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,4 +150,12 @@ public abstract class BackgroundUpdaterTask<T> extends Task.Backgroundable {
|
||||
public boolean isFinished() {
|
||||
return myFinished;
|
||||
}
|
||||
|
||||
public boolean cancelTask() {
|
||||
ProgressIndicator indicator = myIndicator;
|
||||
if (indicator != null) {
|
||||
indicator.cancel();
|
||||
}
|
||||
return setCanceled();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,6 +182,10 @@ public abstract class GotoTargetHandler implements CodeInsightActionHandler {
|
||||
setMovable(true).
|
||||
setCancelCallback(() -> {
|
||||
HintUpdateSupply.hideHint(list);
|
||||
final ListBackgroundUpdaterTask task = gotoData.listUpdaterTask;
|
||||
if (task != null) {
|
||||
return task.cancelTask();
|
||||
}
|
||||
return true;
|
||||
}).
|
||||
setCouldPin(popup1 -> {
|
||||
|
||||
Reference in New Issue
Block a user