EA-807031 - REWA: ApplicationImpl.throwThreadAccessException

GitOrigin-RevId: 08fe7eeb55f864a27c71d68227a3439e7d7a6cd2
This commit is contained in:
Gregory.Shrago
2023-03-12 17:34:26 +00:00
committed by intellij-monorepo-bot
parent e5eaaed240
commit d37f6e87c7
2 changed files with 31 additions and 19 deletions
@@ -701,20 +701,28 @@ public class InspectionResultsView extends JPanel implements Disposable, DataPro
@Override
public Object getData(@NotNull String dataId) {
if (PlatformCoreDataKeys.HELP_ID.is(dataId)) return HELP_ID;
if (DATA_KEY.is(dataId)) return this;
if (ExclusionHandler.EXCLUSION_HANDLER.is(dataId)) return myExclusionHandler;
if (!ApplicationManager.getApplication().isDispatchThread()) return null;
TreePath[] paths = myTree.getSelectionPaths();
if (paths == null || paths.length == 0) return null;
if (PlatformCoreDataKeys.HELP_ID.is(dataId)) {
return HELP_ID;
}
if (DATA_KEY.is(dataId)) {
return this;
}
if (ExclusionHandler.EXCLUSION_HANDLER.is(dataId)) {
return myExclusionHandler;
}
if (PlatformCoreDataKeys.SELECTED_ITEM.is(dataId)) {
TreePath[] paths = myTree.getSelectionPaths();
if (paths == null || paths.length == 0) return null;
return paths[0].getLastPathComponent();
}
if (PlatformCoreDataKeys.SELECTED_ITEMS.is(dataId)) {
TreePath[] paths = myTree.getSelectionPaths();
if (paths == null || paths.length == 0) return null;
return ContainerUtil.map2Array(paths, p -> p.getLastPathComponent());
}
if (PlatformCoreDataKeys.BGT_DATA_PROVIDER.is(dataId)) {
TreePath[] paths = myTree.getSelectionPaths();
if (paths == null || paths.length == 0) return null;
return (DataProvider)slowId -> getSlowData(slowId, paths);
}
return null;
@@ -723,7 +731,7 @@ public class InspectionResultsView extends JPanel implements Disposable, DataPro
private @Nullable Object getSlowData(@NotNull String dataId, TreePath @NotNull [] paths) {
if (paths.length > 1) {
if (PlatformCoreDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) {
RefEntity[] refElements = myTree.getSelectedElements();
RefEntity[] refElements = myTree.getElementsFromSelection(paths);
List<PsiElement> psiElements = new ArrayList<>();
for (RefEntity refElement : refElements) {
PsiElement psiElement = refElement instanceof RefElement ? ((RefElement)refElement).getPsiElement() : null;
@@ -156,10 +156,13 @@ public class InspectionTree extends Tree {
@Nullable
public InspectionToolWrapper<?,?> getSelectedToolWrapper(boolean allowDummy) {
return getSelectedToolWrapper(allowDummy, getSelectionPaths());
}
@Nullable InspectionToolWrapper<?,?> getSelectedToolWrapper(boolean allowDummy, TreePath @Nullable [] paths) {
InspectionProfileImpl profile = myView.getCurrentProfile();
if (profile == null) return null;
String singleToolName = profile.getSingleTool();
final TreePath[] paths = getSelectionPaths();
if (paths == null) {
if (singleToolName != null) {
InspectionToolWrapper<?,?> tool = profile.getInspectionTool(singleToolName, myView.getProject());
@@ -277,18 +280,19 @@ public class InspectionTree extends Tree {
public RefEntity @NotNull [] getSelectedElements() {
TreePath[] selectionPaths = getSelectionPaths();
if (selectionPaths != null) {
InspectionToolWrapper<?,?> toolWrapper = getSelectedToolWrapper(true);
if (toolWrapper == null) return RefEntity.EMPTY_ELEMENTS_ARRAY;
if (selectionPaths == null) return RefEntity.EMPTY_ELEMENTS_ARRAY;
return getElementsFromSelection(selectionPaths);
}
Set<RefEntity> result = new LinkedHashSet<>();
for (TreePath selectionPath : selectionPaths) {
final InspectionTreeNode node = (InspectionTreeNode)selectionPath.getLastPathComponent();
addElementsInNode(node, result);
}
return ArrayUtil.reverseArray(result.toArray(RefEntity.EMPTY_ELEMENTS_ARRAY));
RefEntity @NotNull [] getElementsFromSelection(TreePath @NotNull [] selectionPaths) {
InspectionToolWrapper<?,?> toolWrapper = getSelectedToolWrapper(true, selectionPaths);
if (toolWrapper == null) return RefEntity.EMPTY_ELEMENTS_ARRAY;
Set<RefEntity> result = new LinkedHashSet<>();
for (TreePath selectionPath : selectionPaths) {
final InspectionTreeNode node = (InspectionTreeNode)selectionPath.getLastPathComponent();
addElementsInNode(node, result);
}
return RefEntity.EMPTY_ELEMENTS_ARRAY;
return ArrayUtil.reverseArray(result.toArray(RefEntity.EMPTY_ELEMENTS_ARRAY));
}
@NotNull