mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
show definitions: update in background according to filter
This commit is contained in:
+17
-1
@@ -18,6 +18,8 @@ package com.intellij.codeInsight.hint;
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.ide.highlighter.HighlighterFactory;
|
||||
import com.intellij.ide.ui.ListCellRendererWrapper;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.navigation.NavigationItem;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
@@ -50,6 +52,7 @@ import com.intellij.usages.UsageViewManager;
|
||||
import com.intellij.usages.UsageViewPresentation;
|
||||
import com.intellij.util.PairFunction;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -100,7 +103,20 @@ public class ImplementationViewComponent extends JPanel {
|
||||
|
||||
public FileDescriptor(PsiFile file, PsiElement element) {
|
||||
myFile = file;
|
||||
myElementPresentation = SymbolPresentationUtil.getSymbolPresentableText(element);
|
||||
myElementPresentation = getPresentation(element);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getPresentation(PsiElement element) {
|
||||
if (element instanceof NavigationItem) {
|
||||
final ItemPresentation presentation = ((NavigationItem)element).getPresentation();
|
||||
if (presentation != null) {
|
||||
return presentation.getPresentableText();
|
||||
}
|
||||
}
|
||||
|
||||
if (element instanceof PsiNamedElement) return ((PsiNamedElement)element).getName();
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getPresentableName(VirtualFile vFile) {
|
||||
|
||||
+28
-7
@@ -299,6 +299,7 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
|
||||
private String myCaption;
|
||||
private Editor myEditor;
|
||||
private PsiElement myElement;
|
||||
private PsiElement[] myElements;
|
||||
|
||||
public ImplementationsUpdaterTask(final PsiElement element, final Editor editor, final String caption) {
|
||||
super(element.getProject(), ImplementationSearcher.SEARCHING_FOR_IMPLEMENTATIONS);
|
||||
@@ -318,7 +319,7 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void replaceModel(ArrayList<PsiElement> data) {
|
||||
protected void replaceModel(List<PsiElement> data) {
|
||||
final PsiElement[] elements = myComponent.getElements();
|
||||
final int includeSelfIdx = myElement instanceof PomTargetPsiElement ? 0 : 1;
|
||||
final int startIdx = elements.length - includeSelfIdx;
|
||||
@@ -331,12 +332,32 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
super.run(indicator);
|
||||
getSelfAndImplementations(myEditor, myElement, new ImplementationSearcher.BackgroundableImplementationSearcher() {
|
||||
@Override
|
||||
protected void processElement(PsiElement element) {
|
||||
updateComponent(element, null);
|
||||
}
|
||||
});
|
||||
myElements =
|
||||
getSelfAndImplementations(myEditor, myElement, new ImplementationSearcher.BackgroundableImplementationSearcher() {
|
||||
@Override
|
||||
protected void processElement(PsiElement element) {
|
||||
updateComponent(element, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PsiElement[] filterElements(PsiElement element, PsiElement[] targetElements, int offset) {
|
||||
return ShowImplementationsAction.filterElements(targetElements);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentSize() {
|
||||
if (myElements != null) return myElements.length;
|
||||
return super.getCurrentSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
if (!isCanceled()) {
|
||||
myComponent.update(myElements, myComponent.getIndex());
|
||||
}
|
||||
super.onSuccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -75,13 +75,17 @@ public abstract class BackgroundUpdaterTask<T> extends Task.Backgroundable {
|
||||
}
|
||||
|
||||
public abstract String getCaption(int size);
|
||||
protected abstract void replaceModel(ArrayList<PsiElement> data);
|
||||
protected abstract void replaceModel(List<PsiElement> data);
|
||||
protected abstract void paintBusy(boolean paintBusy);
|
||||
|
||||
public void setCanceled() {
|
||||
myCanceled = true;
|
||||
}
|
||||
|
||||
public boolean isCanceled() {
|
||||
return myCanceled;
|
||||
}
|
||||
|
||||
public void updateComponent(PsiElement element, @Nullable final Comparator comparator) {
|
||||
if (myCanceled) return;
|
||||
if (myPopup.isDisposed()) return;
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ import com.intellij.ui.speedSearch.NameFilteringListModel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
@@ -51,7 +51,7 @@ public abstract class ListBackgroundUpdaterTask extends BackgroundUpdaterTask<JB
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void replaceModel(ArrayList<PsiElement> data) {
|
||||
protected void replaceModel(List<PsiElement> data) {
|
||||
final Object selectedValue = myComponent.getSelectedValue();
|
||||
final int index = myComponent.getSelectedIndex();
|
||||
((NameFilteringListModel)myComponent.getModel()).replaceAll(data);
|
||||
|
||||
Reference in New Issue
Block a user