mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-769294 - PE: DataValidators.reportPsiElementOnEdt
fixing data rules GitOrigin-RevId: d34b357ac7bf75c3ce2462c2b5e7551003a36457
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c3a795f44f
commit
bc84f9421c
@@ -31,6 +31,7 @@ import com.intellij.openapi.util.NlsContexts;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiAwareObject;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.ui.ExperimentalUI;
|
||||
import com.intellij.usages.UsageView;
|
||||
@@ -418,7 +419,7 @@ public abstract class GotoTargetHandler implements CodeInsightActionHandler {
|
||||
}
|
||||
}
|
||||
|
||||
static class ItemWithPresentation {
|
||||
static class ItemWithPresentation implements PsiAwareObject {
|
||||
private ItemWithPresentation(Object item, TargetPresentation presentation) {
|
||||
this.item = item;
|
||||
this.presentation = presentation;
|
||||
@@ -426,5 +427,10 @@ public abstract class GotoTargetHandler implements CodeInsightActionHandler {
|
||||
|
||||
Object item;
|
||||
private TargetPresentation presentation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable PsiElement findElement(@NotNull Project project) {
|
||||
return item instanceof Pointer<?> ? (PsiElement)((Pointer<?>)item).dereference() : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-4
@@ -24,7 +24,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.SmartPsiElementPointer;
|
||||
import com.intellij.psi.util.PsiAwareObject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -48,9 +47,6 @@ public class PsiElementFromSelectionRule implements GetDataRule {
|
||||
element = project == null || !((VirtualFile)item).isValid() ? null :
|
||||
PsiManager.getInstance(project).findFile((VirtualFile)item);
|
||||
}
|
||||
else if (item instanceof SmartPsiElementPointer<?>) {
|
||||
element = ((SmartPsiElementPointer<?>)item).getElement();
|
||||
}
|
||||
return element != null && element.isValid() ? element : null;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -9,7 +9,6 @@ import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.actionSystem.PlatformCoreDataKeys;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.SmartPsiElementPointer;
|
||||
import com.intellij.psi.util.PsiAwareObject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -26,8 +25,7 @@ public class PsiElementFromSelectionsRule implements GetDataRule {
|
||||
Object o = AbstractProjectViewPane.extractValueFromNode(objects[i]);
|
||||
PsiElement element = o instanceof PsiElement ? (PsiElement)o :
|
||||
o instanceof PsiAwareObject && project != null ? ((PsiAwareObject)o).findElement(project) :
|
||||
o instanceof PsiElementNavigationItem ? ((PsiElementNavigationItem)o).getTargetElement() :
|
||||
o instanceof SmartPsiElementPointer<?> ? ((SmartPsiElementPointer<?>)o).getElement() : null;
|
||||
o instanceof PsiElementNavigationItem ? ((PsiElementNavigationItem)o).getTargetElement() : null;
|
||||
if (element == null || !element.isValid()) return null;
|
||||
elements[i] = element;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user