diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java index ae5093972949..a51404bda0a1 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java @@ -1,4 +1,4 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.execution.testframework.sm.runner; import com.intellij.execution.Location; @@ -17,6 +17,8 @@ import com.intellij.ide.DataManager; import com.intellij.ide.nls.NlsMessages; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.ExecutionDataKeys; +import com.intellij.openapi.application.ModalityState; +import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; @@ -30,6 +32,7 @@ import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.util.CachedValue; import com.intellij.psi.util.CachedValueProvider; import com.intellij.psi.util.CachedValuesManager; +import com.intellij.util.concurrency.AppExecutorUtil; import com.intellij.util.concurrency.annotations.RequiresEdt; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; @@ -46,7 +49,7 @@ import java.util.concurrent.CopyOnWriteArrayList; * * @author Roman Chernyatchik */ -public class SMTestProxy extends AbstractTestProxy { +public class SMTestProxy extends AbstractTestProxy implements Navigatable { public static final Key NODE_ID = Key.create("test.proxy.id"); private static final Logger LOG = Logger.getInstance(SMTestProxy.class.getName()); @@ -268,6 +271,34 @@ public class SMTestProxy extends AbstractTestProxy { return myConfig; } + private Navigatable getNavigatable() { + SMRootTestProxy root = getRoot(); + if (root == null) return null; + return TestsUIUtil.getOpenFileDescriptor(this, root.myTestConsoleProperties); + } + + @Override + public void navigate(boolean requestFocus) { + ReadAction.nonBlocking(() -> getNavigatable()) + .expireWith(this) + .finishOnUiThread(ModalityState.NON_MODAL, navigatable -> { + if (navigatable != null) { + navigatable.navigate(requestFocus); + } + }).submit(AppExecutorUtil.getAppExecutorService()); + } + + @Override + public boolean canNavigate() { + Navigatable navigatable = getNavigatable(); + return navigatable != null && navigatable.canNavigate(); + } + + @Override + public boolean canNavigateToSource() { + return canNavigate(); + } + @Override @Nullable public Location getLocation(@NotNull Project project, @NotNull GlobalSearchScope searchScope) { diff --git a/platform/testRunner/src/com/intellij/execution/testframework/TestTreeView.java b/platform/testRunner/src/com/intellij/execution/testframework/TestTreeView.java index 1343e4f8d065..bd1880aca0c2 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/TestTreeView.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/TestTreeView.java @@ -1,4 +1,4 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.execution.testframework; import com.intellij.execution.Location; @@ -102,9 +102,10 @@ public abstract class TestTreeView extends Tree implements DataProvider, CopyPro AbstractTestProxy testProxy = getSelectedTest(selectionPath); if (testProxy == null) return null; - if (AbstractTestProxy.DATA_KEY.is(dataId)) { + if (AbstractTestProxy.DATA_KEY.is(dataId) || CommonDataKeys.NAVIGATABLE.is(dataId)) { return testProxy; } + if (PlatformDataKeys.SLOW_DATA_PROVIDERS.is(dataId)) { TestFrameworkRunningModel model = myModel; return Collections.singletonList(dataId1 -> getSlowData(dataId1, testProxy, model)); @@ -125,10 +126,7 @@ public abstract class TestTreeView extends Tree implements DataProvider, CopyPro @NotNull TestFrameworkRunningModel model) { Project project = model.getProperties().getProject(); - if (CommonDataKeys.NAVIGATABLE.is(dataId)) { - return TestsUIUtil.getOpenFileDescriptor(testProxy, model); - } - else if (CommonDataKeys.PSI_ELEMENT.is(dataId)) { + if (CommonDataKeys.PSI_ELEMENT.is(dataId)) { Location location = testProxy.getLocation(project, model.getProperties().getScope()); PsiElement psiElement = location != null ? location.getPsiElement() : null; return psiElement == null || !psiElement.isValid() ? null : psiElement;