mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-92679 Deadlock due to unsafe event dispatch thread use
This commit is contained in:
+14
-9
@@ -25,6 +25,7 @@ import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.navigation.GotoRelatedItem;
|
||||
import com.intellij.openapi.editor.markup.GutterIconRenderer;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.SmartPointerManager;
|
||||
@@ -70,7 +71,7 @@ public class NavigationGutterIconBuilder<T> {
|
||||
private String myEmptyText;
|
||||
private String myTooltipTitle;
|
||||
private GutterIconRenderer.Alignment myAlignment = GutterIconRenderer.Alignment.CENTER;
|
||||
private PsiElementListCellRenderer myCellRenderer;
|
||||
private Computable<PsiElementListCellRenderer> myCellRenderer;
|
||||
private NullableFunction<T,String> myNamer = ElementPresentationManager.namer();
|
||||
private final NotNullFunction<T, Collection<? extends GotoRelatedItem>> myGotoRelatedItemProvider;
|
||||
public static final NotNullFunction<DomElement,Collection<? extends PsiElement>> DEFAULT_DOM_CONVERTOR = new NotNullFunction<DomElement, Collection<? extends PsiElement>>() {
|
||||
@@ -179,7 +180,7 @@ public class NavigationGutterIconBuilder<T> {
|
||||
}
|
||||
|
||||
public NavigationGutterIconBuilder<T> setCellRenderer(@NotNull final PsiElementListCellRenderer cellRenderer) {
|
||||
myCellRenderer = cellRenderer;
|
||||
myCellRenderer = new Computable.PredefinedValueComputable<PsiElementListCellRenderer>(cellRenderer);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -267,11 +268,14 @@ public class NavigationGutterIconBuilder<T> {
|
||||
myTooltipText = sb.toString();
|
||||
}
|
||||
|
||||
if (myCellRenderer == null) {
|
||||
myCellRenderer = new DefaultPsiElementCellRenderer();
|
||||
}
|
||||
|
||||
return new MyNavigationGutterIconRenderer(this, myAlignment, myIcon, myTooltipText, pointers, empty);
|
||||
Computable<PsiElementListCellRenderer> renderer =
|
||||
myCellRenderer == null ? new Computable<PsiElementListCellRenderer>() {
|
||||
@Override
|
||||
public PsiElementListCellRenderer compute() {
|
||||
return new DefaultPsiElementCellRenderer();
|
||||
}
|
||||
} : myCellRenderer;
|
||||
return new MyNavigationGutterIconRenderer(this, myAlignment, myIcon, myTooltipText, pointers, renderer, empty);
|
||||
}
|
||||
|
||||
private boolean isEmpty() {
|
||||
@@ -300,10 +304,11 @@ public class NavigationGutterIconBuilder<T> {
|
||||
public MyNavigationGutterIconRenderer(@NotNull NavigationGutterIconBuilder builder,
|
||||
final Alignment alignment,
|
||||
final Icon icon,
|
||||
final String tooltipText,
|
||||
@Nullable final String tooltipText,
|
||||
@NotNull NotNullLazyValue<List<SmartPsiElementPointer>> pointers,
|
||||
Computable<PsiElementListCellRenderer> cellRenderer,
|
||||
boolean empty) {
|
||||
super(builder.myPopupTitle, builder.myEmptyText, builder.myCellRenderer, pointers);
|
||||
super(builder.myPopupTitle, builder.myEmptyText, cellRenderer, pointers);
|
||||
myAlignment = alignment;
|
||||
myIcon = icon;
|
||||
myTooltipText = tooltipText;
|
||||
|
||||
+6
-9
@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.markup.GutterIconRenderer;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.SmartPsiElementPointer;
|
||||
@@ -46,11 +47,11 @@ import java.util.List;
|
||||
public abstract class NavigationGutterIconRenderer extends GutterIconRenderer implements GutterIconNavigationHandler<PsiElement>{
|
||||
private final String myPopupTitle;
|
||||
private final String myEmptyText;
|
||||
private final PsiElementListCellRenderer myCellRenderer;
|
||||
private final Computable<PsiElementListCellRenderer> myCellRenderer;
|
||||
private final NotNullLazyValue<List<SmartPsiElementPointer>> myPointers;
|
||||
|
||||
protected NavigationGutterIconRenderer(final String popupTitle, final String emptyText, @NotNull PsiElementListCellRenderer cellRenderer,
|
||||
@NotNull NotNullLazyValue<List<SmartPsiElementPointer>> pointers) {
|
||||
protected NavigationGutterIconRenderer(final String popupTitle, final String emptyText, @NotNull Computable<PsiElementListCellRenderer> cellRenderer,
|
||||
@NotNull NotNullLazyValue<List<SmartPsiElementPointer>> pointers) {
|
||||
myPopupTitle = popupTitle;
|
||||
myEmptyText = emptyText;
|
||||
myCellRenderer = cellRenderer;
|
||||
@@ -90,10 +91,6 @@ public abstract class NavigationGutterIconRenderer extends GutterIconRenderer im
|
||||
return result;
|
||||
}
|
||||
|
||||
public PsiElementListCellRenderer getCellRenderer() {
|
||||
return myCellRenderer;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public AnAction getClickAction() {
|
||||
return new AnAction() {
|
||||
@@ -103,7 +100,7 @@ public abstract class NavigationGutterIconRenderer extends GutterIconRenderer im
|
||||
};
|
||||
}
|
||||
|
||||
public void navigate(final MouseEvent event, final PsiElement elt) {
|
||||
public void navigate(@Nullable final MouseEvent event, @Nullable final PsiElement elt) {
|
||||
final List<PsiElement> list = getTargetElements();
|
||||
if (list.isEmpty()) {
|
||||
if (myEmptyText != null) {
|
||||
@@ -125,7 +122,7 @@ public abstract class NavigationGutterIconRenderer extends GutterIconRenderer im
|
||||
}
|
||||
else {
|
||||
if (event != null) {
|
||||
final JBPopup popup = NavigationUtil.getPsiElementPopup(PsiUtilCore.toPsiElementArray(list), myCellRenderer, myPopupTitle);
|
||||
final JBPopup popup = NavigationUtil.getPsiElementPopup(PsiUtilCore.toPsiElementArray(list), myCellRenderer.compute(), myPopupTitle);
|
||||
popup.show(new RelativePoint(event));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user