From 036cf32e8be805e7ee465f2b8a7560a5ae5ee632 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 13 Dec 2016 17:51:34 +0100 Subject: [PATCH] Cleanup (drops unused deprecated code) --- .../testIntegration/TestLocationProvider.java | 6 +- .../sm/CompositeTestLocationProvider.java | 74 ------------ .../sm/SMTestRunnerConnectionUtil.java | 107 +++++++++--------- 3 files changed, 55 insertions(+), 132 deletions(-) delete mode 100644 platform/smRunner/src/com/intellij/execution/testframework/sm/CompositeTestLocationProvider.java diff --git a/platform/lang-impl/src/com/intellij/testIntegration/TestLocationProvider.java b/platform/lang-impl/src/com/intellij/testIntegration/TestLocationProvider.java index 46405692e24d..09541609c9b8 100644 --- a/platform/lang-impl/src/com/intellij/testIntegration/TestLocationProvider.java +++ b/platform/lang-impl/src/com/intellij/testIntegration/TestLocationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,10 +22,10 @@ import org.jetbrains.annotations.NotNull; import java.util.List; -/** @deprecated override SMTRunnerConsoleProperties.getTestLocator() instead (to be removed in IDEA 16) */ +/** @deprecated override SMTRunnerConsoleProperties.getTestLocator() instead (to be removed in IDEA 17) */ public interface TestLocationProvider { @SuppressWarnings("deprecation") ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.testSrcLocator"); @NotNull List getLocation(@NotNull String protocolId, @NotNull String locationData, Project project); -} +} \ No newline at end of file diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/CompositeTestLocationProvider.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/CompositeTestLocationProvider.java deleted file mode 100644 index 797bd41d639b..000000000000 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/CompositeTestLocationProvider.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.execution.testframework.sm; - -import com.intellij.execution.Location; -import com.intellij.execution.testframework.sm.runner.SMTestLocator; -import com.intellij.openapi.extensions.Extensions; -import com.intellij.openapi.project.DumbAware; -import com.intellij.openapi.project.DumbService; -import com.intellij.openapi.project.Project; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.testIntegration.TestLocationProvider; -import com.intellij.util.io.URLUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Collections; -import java.util.List; - -/** to be removed in IDEA 16 */ -public class CompositeTestLocationProvider implements SMTestLocator { - @SuppressWarnings("deprecation") private final TestLocationProvider myPrimaryLocator; - @SuppressWarnings("deprecation") private final TestLocationProvider[] myLocators; - - @SuppressWarnings("deprecation") - public CompositeTestLocationProvider(@Nullable TestLocationProvider primaryLocator) { - myPrimaryLocator = primaryLocator; - myLocators = Extensions.getExtensions(TestLocationProvider.EP_NAME); - } - - @NotNull - @Override - public List getLocation(@NotNull String protocol, @NotNull String path, @NotNull Project project, @NotNull GlobalSearchScope scope) { - boolean isDumbMode = DumbService.isDumb(project); - - if (myPrimaryLocator != null && (!isDumbMode || myPrimaryLocator instanceof DumbAware)) { - List locations = myPrimaryLocator.getLocation(protocol, path, project); - if (!locations.isEmpty()) { - return locations; - } - } - - if (URLUtil.FILE_PROTOCOL.equals(protocol)) { - List locations = FileUrlProvider.INSTANCE.getLocation(protocol, path, project, scope); - if (!locations.isEmpty()) { - return locations; - } - } - - for (@SuppressWarnings("deprecation") TestLocationProvider provider : myLocators) { - if (!isDumbMode || provider instanceof DumbAware) { - List locations = provider.getLocation(protocol, path, project); - if (!locations.isEmpty()) { - return locations; - } - } - } - - return Collections.emptyList(); - } -} diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestRunnerConnectionUtil.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestRunnerConnectionUtil.java index 23c5f1d0ba60..b2be60173074 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestRunnerConnectionUtil.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestRunnerConnectionUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,10 +16,7 @@ package com.intellij.execution.testframework.sm; import com.intellij.execution.ExecutionException; -import com.intellij.execution.Executor; import com.intellij.execution.Location; -import com.intellij.execution.configurations.CommandLineState; -import com.intellij.execution.configurations.ModuleRunConfiguration; import com.intellij.execution.process.ProcessAdapter; import com.intellij.execution.process.ProcessEvent; import com.intellij.execution.process.ProcessHandler; @@ -31,7 +28,7 @@ import com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView; import com.intellij.execution.testframework.sm.runner.ui.SMTRunnerUIActionsHandler; import com.intellij.execution.testframework.sm.runner.ui.SMTestRunnerResultsForm; import com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView; -import com.intellij.execution.ui.ConsoleView; +import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; @@ -167,13 +164,13 @@ public class SMTestRunnerConnectionUtil { return Boolean.valueOf(System.getProperty(TEST_RUNNER_DEBUG_MODE_PROPERTY)); } - private static ProcessHandler attachEventsProcessors(TestConsoleProperties consoleProperties, - SMTestRunnerResultsForm resultsViewer, - ProcessHandler processHandler, - String testFrameworkName, - @Nullable SMTestLocator locator, - boolean idBasedTestTree, - @Nullable TestProxyPrinterProvider printerProvider) { + private static void attachEventsProcessors(TestConsoleProperties consoleProperties, + SMTestRunnerResultsForm resultsViewer, + ProcessHandler processHandler, + String testFrameworkName, + @Nullable SMTestLocator locator, + boolean idBasedTestTree, + @Nullable TestProxyPrinterProvider printerProvider) { // build messages consumer final OutputToGeneralTestEventsConverter outputConsumer; if (consoleProperties instanceof SMCustomMessagesParsing) { @@ -233,8 +230,6 @@ public class SMTestRunnerConnectionUtil { outputConsumer.process(event.getText(), outputType); } }); - - return processHandler; } private static class CombinedTestLocator implements SMTestLocator, DumbAware { @@ -259,26 +254,7 @@ public class SMTestRunnerConnectionUtil { } } - /** @deprecated use {@link #createAndAttachConsole(String, ProcessHandler, TestConsoleProperties)} (to be removed in IDEA 16) */ - @SuppressWarnings({"unused", "deprecation"}) - public static BaseTestsOutputConsoleView createAndAttachConsole(@NotNull String testFrameworkName, - @NotNull ProcessHandler processHandler, - @NotNull TestConsoleProperties consoleProperties, - ExecutionEnvironment environment) throws ExecutionException { - BaseTestsOutputConsoleView console = createConsole(testFrameworkName, consoleProperties, environment); - console.attachToProcess(processHandler); - return console; - } - - /** @deprecated use {@link SMTestRunnerConnectionUtil#createConsole(String, TestConsoleProperties)} instead (to be removed in IDEA 16) */ - @SuppressWarnings({"unused", "deprecation"}) - public static BaseTestsOutputConsoleView createConsole(@NotNull String testFrameworkName, - @NotNull TestConsoleProperties consoleProperties, - ExecutionEnvironment environment) { - return createConsoleWithCustomLocator(testFrameworkName, consoleProperties, environment, null); - } - - /** @deprecated use {@link #createConsole(String, TestConsoleProperties)} (to be removed in IDEA 16) */ + /** @deprecated use {@link #createConsole(String, TestConsoleProperties)} (to be removed in IDEA 17) */ @SuppressWarnings({"unused", "deprecation"}) public static BaseTestsOutputConsoleView createConsoleWithCustomLocator(@NotNull String testFrameworkName, @NotNull TestConsoleProperties consoleProperties, @@ -287,7 +263,7 @@ public class SMTestRunnerConnectionUtil { return createConsoleWithCustomLocator(testFrameworkName, consoleProperties, environment, locator, false, null); } - /** @deprecated use {@link #createConsole(String, TestConsoleProperties)} (to be removed in IDEA 16) */ + /** @deprecated use {@link #createConsole(String, TestConsoleProperties)} (to be removed in IDEA 17) */ @SuppressWarnings({"unused", "deprecation"}) public static SMTRunnerConsoleView createConsoleWithCustomLocator(@NotNull String testFrameworkName, @NotNull TestConsoleProperties consoleProperties, @@ -301,7 +277,7 @@ public class SMTestRunnerConnectionUtil { return consoleView; } - /** @deprecated use {@link #initConsoleView(SMTRunnerConsoleView, String)} (to be removed in IDEA 16) */ + /** @deprecated use {@link #initConsoleView(SMTRunnerConsoleView, String)} (to be removed in IDEA 17) */ @SuppressWarnings({"unused", "deprecation"}) public static void initConsoleView(@NotNull final SMTRunnerConsoleView consoleView, @NotNull final String testFrameworkName, @@ -334,24 +310,45 @@ public class SMTestRunnerConnectionUtil { consoleView.initUI(); } - /** @deprecated use {@link #createAndAttachConsole(String, ProcessHandler, TestConsoleProperties)} (to be removed in IDEA 16) */ - @SuppressWarnings({"unused", "deprecation"}) - public static ConsoleView createAndAttachConsole(@NotNull String testFrameworkName, - @NotNull ProcessHandler processHandler, - @NotNull CommandLineState commandLineState, - @NotNull ModuleRunConfiguration config, - @NotNull Executor executor) throws ExecutionException { - TestConsoleProperties consoleProperties = new SMTRunnerConsoleProperties(config, testFrameworkName, executor); - return createAndAttachConsole(testFrameworkName, processHandler, consoleProperties, commandLineState.getEnvironment()); - } + @SuppressWarnings("deprecation") + private static class CompositeTestLocationProvider implements SMTestLocator { + private final TestLocationProvider myPrimaryLocator; + private final TestLocationProvider[] myLocators; - /** @deprecated use {@link #createConsole(String, TestConsoleProperties)} (to be removed in IDEA 16) */ - @SuppressWarnings({"unused", "deprecation"}) - public static ConsoleView createConsole(@NotNull String testFrameworkName, - @NotNull CommandLineState commandLineState, - @NotNull ModuleRunConfiguration config, - @NotNull Executor executor) throws ExecutionException { - TestConsoleProperties consoleProperties = new SMTRunnerConsoleProperties(config, testFrameworkName, executor); - return createConsole(testFrameworkName, consoleProperties, commandLineState.getEnvironment()); + private CompositeTestLocationProvider(@Nullable TestLocationProvider primaryLocator) { + myPrimaryLocator = primaryLocator; + myLocators = Extensions.getExtensions(TestLocationProvider.EP_NAME); + } + + @NotNull + @Override + public List getLocation(@NotNull String protocol, @NotNull String path, @NotNull Project project, @NotNull GlobalSearchScope scope) { + boolean isDumbMode = DumbService.isDumb(project); + + if (myPrimaryLocator != null && (!isDumbMode || myPrimaryLocator instanceof DumbAware)) { + List locations = myPrimaryLocator.getLocation(protocol, path, project); + if (!locations.isEmpty()) { + return locations; + } + } + + if (URLUtil.FILE_PROTOCOL.equals(protocol)) { + List locations = FileUrlProvider.INSTANCE.getLocation(protocol, path, project, scope); + if (!locations.isEmpty()) { + return locations; + } + } + + for (TestLocationProvider provider : myLocators) { + if (!isDumbMode || provider instanceof DumbAware) { + List locations = provider.getLocation(protocol, path, project); + if (!locations.isEmpty()) { + return locations; + } + } + } + + return Collections.emptyList(); + } } -} +} \ No newline at end of file