Skip to content

Commit 1def10f

Browse files
authored
fix: Remove the refresh Java tests command (#1385)
* fix: Remove the refresh Java tests command - since the platform already registered the command in palette, the existing one from Java side can be removed. Signed-off-by: sheche <sheche@microsoft.com>
1 parent 0edf7b1 commit 1def10f

File tree

7 files changed

+10
-16
lines changed

7 files changed

+10
-16
lines changed

package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,6 @@
162162
"command": "java.test.editor.debug",
163163
"title": "%contributes.commands.java.test.editor.debug.title%",
164164
"category": "Java"
165-
},
166-
{
167-
"command": "java.test.refreshExplorer",
168-
"title": "%contributes.commands.java.test.refreshExplorer.title%",
169-
"category": "Java"
170165
}
171166
],
172167
"configuration": {

package.nls.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"contributes.commands.java.test.editor.debug.title": "Debug Tests",
55
"contributes.commands.java.test.runFromJavaProjectExplorer.title": "Run Tests",
66
"contributes.commands.java.test.debugFromJavaProjectExplorer.title": "Debug Tests",
7-
"contributes.commands.java.test.refreshExplorer.title": "Refresh Tests",
87
"contributes.commands.java.test.goToTest.title": "Go to Test",
98
"contributes.commands.java.test.goToTestSubject.title": "Go to Test Subject",
109
"configuration.java.test.defaultConfig.description": "Specify the name of the default test configuration",

package.nls.zh.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"contributes.commands.java.test.editor.debug.title": "调试测试用例",
55
"contributes.commands.java.test.runFromJavaProjectExplorer.title": "运行测试",
66
"contributes.commands.java.test.debugFromJavaProjectExplorer.title": "调试测试",
7-
"contributes.commands.java.test.refreshExplorer.title": "刷新测试",
87
"contributes.commands.java.test.goToTest.title": "转到测试",
98
"contributes.commands.java.test.goToTestSubject.title": "转到被测试代码",
109
"configuration.java.test.defaultConfig.description": "设定默认测试配置项的名称",

src/commands/testExplorerCommands.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT license.
33

44
import { DebugConfiguration, TestItem, TestRunRequest } from 'vscode';
5+
import { sendInfo } from 'vscode-extension-telemetry-wrapper';
56
import { runTests, testController } from '../controller/testController';
67
import { loadJavaProjects } from '../controller/utils';
78
import { showTestItemsInCurrentFile } from '../extension';
@@ -36,7 +37,8 @@ export async function runTestsFromTestExplorer(testItem: TestItem, launchConfigu
3637
await runTests(request, { launchConfiguration, isDebug });
3738
}
3839

39-
export async function refresh(): Promise<void> {
40+
export async function refreshExplorer(): Promise<void> {
41+
sendInfo('', { name: 'refreshTests' });
4042
testController?.items.forEach((root: TestItem) => {
4143
testController?.items.delete(root.id);
4244
});

src/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export namespace JavaTestRunnerCommands {
2525
export const DEBUG_TEST_FROM_JAVA_PROJECT_EXPLORER: string = 'java.test.debugFromJavaProjectExplorer';
2626
export const RUN_FROM_TEST_EXPLORER: string = 'java.test.explorer.run';
2727
export const DEBUG_FROM_TEST_EXPLORER: string = 'java.test.explorer.debug';
28-
export const REFRESH_TEST_EXPLORER: string = 'java.test.refreshExplorer';
2928
export const JAVA_TEST_GENERATE_TESTS: string = 'java.test.generateTests';
3029
export const FIND_TEST_LOCATION: string = 'vscode.java.test.findTestLocation';
3130
export const GO_TO_TEST: string = 'java.test.goToTest';

src/controller/testController.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
// Licensed under the MIT license.
33

44
import * as _ from 'lodash';
5-
import { CancellationToken, commands, DebugConfiguration, Disposable, FileSystemWatcher, RelativePattern, TestController, TestItem, TestRun, TestRunProfileKind, TestRunRequest, tests, TestTag, Uri, window, workspace, WorkspaceFolder } from 'vscode';
5+
import { CancellationToken, DebugConfiguration, Disposable, FileSystemWatcher, RelativePattern, TestController, TestItem, TestRun, TestRunProfileKind, TestRunRequest, tests, TestTag, Uri, window, workspace, WorkspaceFolder } from 'vscode';
66
import { instrumentOperation, sendError, sendInfo } from 'vscode-extension-telemetry-wrapper';
7-
import { INVOCATION_PREFIX, JavaTestRunnerCommands } from '../constants';
7+
import { refreshExplorer } from '../commands/testExplorerCommands';
8+
import { INVOCATION_PREFIX } from '../constants';
89
import { IProgressReporter } from '../debugger.api';
910
import { isStandardServerReady, progressProvider } from '../extension';
1011
import { testSourceProvider } from '../provider/testSourceProvider';
@@ -37,7 +38,7 @@ export function createTestController(): void {
3738
testController.createRunProfile('Debug Tests', TestRunProfileKind.Debug, runHandler, true, runnableTag);
3839

3940
testController.refreshHandler = () => {
40-
commands.executeCommand(JavaTestRunnerCommands.REFRESH_TEST_EXPLORER);
41+
refreshExplorer();
4142
}
4243

4344
startWatchingWorkspace();

src/extension.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { dispose as disposeTelemetryWrapper, initializeFromJsonFile, instrumentO
77
import { navigateToTestOrTarget } from './commands/navigation/navigationCommands';
88
import { generateTests } from './commands/generationCommands';
99
import { runTestsFromJavaProjectExplorer } from './commands/projectExplorerCommands';
10-
import { refresh, runTestsFromTestExplorer } from './commands/testExplorerCommands';
10+
import { refreshExplorer, runTestsFromTestExplorer } from './commands/testExplorerCommands';
1111
import { openStackTrace } from './commands/testReportCommands';
1212
import { Context, ExtensionName, JavaTestRunnerCommands, VSCodeCommands } from './constants';
1313
import { createTestController, testController, watchers } from './controller/testController';
@@ -65,7 +65,7 @@ async function doActivate(_operationId: string, context: ExtensionContext): Prom
6565
// workaround: wait more time to make sure Language Server has updated all caches
6666
setTimeout(() => {
6767
testSourceProvider.clear();
68-
commands.executeCommand(JavaTestRunnerCommands.REFRESH_TEST_EXPLORER);
68+
refreshExplorer();
6969
}, 1000 /*ms*/);
7070
}));
7171
}
@@ -74,7 +74,7 @@ async function doActivate(_operationId: string, context: ExtensionContext): Prom
7474
const onDidProjectsImport: Event<Uri[]> = extensionApi.onDidProjectsImport;
7575
context.subscriptions.push(onDidProjectsImport(async () => {
7676
testSourceProvider.clear();
77-
commands.executeCommand(JavaTestRunnerCommands.REFRESH_TEST_EXPLORER);
77+
refreshExplorer();
7878
}));
7979
}
8080

@@ -107,7 +107,6 @@ function registerComponents(context: ExtensionContext): void {
107107
instrumentOperationAsVsCodeCommand(JavaTestRunnerCommands.JAVA_TEST_GENERATE_TESTS, ((uri: Uri, startPosition: number) => generateTests(uri, startPosition))),
108108
instrumentOperationAsVsCodeCommand(JavaTestRunnerCommands.RUN_FROM_TEST_EXPLORER, async (node: TestItem, launchConfiguration: DebugConfiguration) => await runTestsFromTestExplorer(node, launchConfiguration, false)),
109109
instrumentOperationAsVsCodeCommand(JavaTestRunnerCommands.DEBUG_FROM_TEST_EXPLORER, async (node: TestItem, launchConfiguration: DebugConfiguration) => await runTestsFromTestExplorer(node, launchConfiguration, false)),
110-
instrumentOperationAsVsCodeCommand(JavaTestRunnerCommands.REFRESH_TEST_EXPLORER, async () => await refresh()),
111110
instrumentOperationAsVsCodeCommand(JavaTestRunnerCommands.RUN_TEST_FROM_JAVA_PROJECT_EXPLORER, async (node: any) => await runTestsFromJavaProjectExplorer(node, false /* isDebug */)),
112111
instrumentOperationAsVsCodeCommand(JavaTestRunnerCommands.DEBUG_TEST_FROM_JAVA_PROJECT_EXPLORER, async (node: any) => await runTestsFromJavaProjectExplorer(node, true /* isDebug */)),
113112
instrumentOperationAsVsCodeCommand(JavaTestRunnerCommands.GO_TO_TEST, async () => await navigateToTestOrTarget(true)),

0 commit comments

Comments
 (0)