Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove the refresh Java tests command #1385

Merged
merged 3 commits into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,6 @@
"command": "java.test.editor.debug",
"title": "%contributes.commands.java.test.editor.debug.title%",
"category": "Java"
},
{
"command": "java.test.refreshExplorer",
"title": "%contributes.commands.java.test.refreshExplorer.title%",
"category": "Java"
}
],
"configuration": {
Expand Down
1 change: 0 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"contributes.commands.java.test.editor.debug.title": "Debug Tests",
"contributes.commands.java.test.runFromJavaProjectExplorer.title": "Run Tests",
"contributes.commands.java.test.debugFromJavaProjectExplorer.title": "Debug Tests",
"contributes.commands.java.test.refreshExplorer.title": "Refresh Tests",
"contributes.commands.java.test.goToTest.title": "Go to Test",
"contributes.commands.java.test.goToTestSubject.title": "Go to Test Subject",
"configuration.java.test.defaultConfig.description": "Specify the name of the default test configuration",
Expand Down
1 change: 0 additions & 1 deletion package.nls.zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"contributes.commands.java.test.editor.debug.title": "调试测试用例",
"contributes.commands.java.test.runFromJavaProjectExplorer.title": "运行测试",
"contributes.commands.java.test.debugFromJavaProjectExplorer.title": "调试测试",
"contributes.commands.java.test.refreshExplorer.title": "刷新测试",
"contributes.commands.java.test.goToTest.title": "转到测试",
"contributes.commands.java.test.goToTestSubject.title": "转到被测试代码",
"configuration.java.test.defaultConfig.description": "设定默认测试配置项的名称",
Expand Down
4 changes: 3 additions & 1 deletion src/commands/testExplorerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license.

import { DebugConfiguration, TestItem, TestRunRequest } from 'vscode';
import { sendInfo } from 'vscode-extension-telemetry-wrapper';
import { runTests, testController } from '../controller/testController';
import { loadJavaProjects } from '../controller/utils';
import { showTestItemsInCurrentFile } from '../extension';
Expand Down Expand Up @@ -36,7 +37,8 @@ export async function runTestsFromTestExplorer(testItem: TestItem, launchConfigu
await runTests(request, { launchConfiguration, isDebug });
}

export async function refresh(): Promise<void> {
export async function refreshExplorer(): Promise<void> {
sendInfo('', { name: 'refreshTests' });
testController?.items.forEach((root: TestItem) => {
testController?.items.delete(root.id);
});
Expand Down
1 change: 0 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export namespace JavaTestRunnerCommands {
export const DEBUG_TEST_FROM_JAVA_PROJECT_EXPLORER: string = 'java.test.debugFromJavaProjectExplorer';
export const RUN_FROM_TEST_EXPLORER: string = 'java.test.explorer.run';
export const DEBUG_FROM_TEST_EXPLORER: string = 'java.test.explorer.debug';
export const REFRESH_TEST_EXPLORER: string = 'java.test.refreshExplorer';
export const JAVA_TEST_GENERATE_TESTS: string = 'java.test.generateTests';
export const FIND_TEST_LOCATION: string = 'vscode.java.test.findTestLocation';
export const GO_TO_TEST: string = 'java.test.goToTest';
Expand Down
7 changes: 4 additions & 3 deletions src/controller/testController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// Licensed under the MIT license.

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

testController.refreshHandler = () => {
commands.executeCommand(JavaTestRunnerCommands.REFRESH_TEST_EXPLORER);
refreshExplorer();
}

startWatchingWorkspace();
Expand Down
7 changes: 3 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { dispose as disposeTelemetryWrapper, initializeFromJsonFile, instrumentO
import { navigateToTestOrTarget } from './commands/navigation/navigationCommands';
import { generateTests } from './commands/generationCommands';
import { runTestsFromJavaProjectExplorer } from './commands/projectExplorerCommands';
import { refresh, runTestsFromTestExplorer } from './commands/testExplorerCommands';
import { refreshExplorer, runTestsFromTestExplorer } from './commands/testExplorerCommands';
import { openStackTrace } from './commands/testReportCommands';
import { Context, ExtensionName, JavaTestRunnerCommands, VSCodeCommands } from './constants';
import { createTestController, testController, watchers } from './controller/testController';
Expand Down Expand Up @@ -65,7 +65,7 @@ async function doActivate(_operationId: string, context: ExtensionContext): Prom
// workaround: wait more time to make sure Language Server has updated all caches
setTimeout(() => {
testSourceProvider.clear();
commands.executeCommand(JavaTestRunnerCommands.REFRESH_TEST_EXPLORER);
refreshExplorer();
}, 1000 /*ms*/);
}));
}
Expand All @@ -74,7 +74,7 @@ async function doActivate(_operationId: string, context: ExtensionContext): Prom
const onDidProjectsImport: Event<Uri[]> = extensionApi.onDidProjectsImport;
context.subscriptions.push(onDidProjectsImport(async () => {
testSourceProvider.clear();
commands.executeCommand(JavaTestRunnerCommands.REFRESH_TEST_EXPLORER);
refreshExplorer();
}));
}

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