Unscope mock commands

This reverts commit 57ba12db8b.
This commit is contained in:
Koen Vlaswinkel
2022-10-21 13:12:38 +02:00
parent 74ae5a7fdc
commit 7288712e47
4 changed files with 18 additions and 37 deletions

View File

@@ -647,16 +647,16 @@
"enablement": "codeql.hasQLSource"
},
{
"command": "codeQLMockGitHubApiServer.startRecording",
"title": "CodeQL Mock GitHub API Server: Start Scenario Recording"
"command": "codeQL.mockGitHubApiServer.startRecording",
"title": "CodeQL: Mock GitHub API Server: Start Scenario Recording"
},
{
"command": "codeQLMockGitHubApiServer.saveScenario",
"title": "CodeQL Mock GitHub API Server: Save Scenario"
"command": "codeQL.mockGitHubApiServer.saveScenario",
"title": "CodeQL: Mock GitHub API Server: Save Scenario"
},
{
"command": "codeQLMockGitHubApiServer.cancelRecording",
"title": "CodeQL Mock GitHub API Server: Cancel Scenario Recording"
"command": "codeQL.mockGitHubApiServer.cancelRecording",
"title": "CodeQL: Mock GitHub API Server: Cancel Scenario Recording"
}
],
"menus": {
@@ -1118,16 +1118,16 @@
"when": "false"
},
{
"command": "codeQLMockGitHubApiServer.startRecording",
"when": "config.codeQL.variantAnalysis.mockGitHubApiServer && !codeQLMockGitHubApiServer.recording"
"command": "codeQL.mockGitHubApiServer.startRecording",
"when": "config.codeQL.variantAnalysis.mockGitHubApiServer && !codeQL.mockGitHubApiServer.recording"
},
{
"command": "codeQLMockGitHubApiServer.saveScenario",
"when": "config.codeQL.variantAnalysis.mockGitHubApiServer && codeQLMockGitHubApiServer.recording"
"command": "codeQL.mockGitHubApiServer.saveScenario",
"when": "config.codeQL.variantAnalysis.mockGitHubApiServer && codeQL.mockGitHubApiServer.recording"
},
{
"command": "codeQLMockGitHubApiServer.cancelRecording",
"when": "config.codeQL.variantAnalysis.mockGitHubApiServer && codeQLMockGitHubApiServer.recording"
"command": "codeQL.mockGitHubApiServer.cancelRecording",
"when": "config.codeQL.variantAnalysis.mockGitHubApiServer && codeQL.mockGitHubApiServer.recording"
}
],
"editor/context": [

View File

@@ -1195,19 +1195,19 @@ async function activateWithInstalledDistribution(
ctx.subscriptions.push(mockServer);
ctx.subscriptions.push(
commandRunner(
'codeQLMockGitHubApiServer.startRecording',
'codeQL.mockGitHubApiServer.startRecording',
async () => await mockServer.startRecording(),
)
);
ctx.subscriptions.push(
commandRunner(
'codeQLMockGitHubApiServer.saveScenario',
'codeQL.mockGitHubApiServer.saveScenario',
async () => await mockServer.saveScenario(),
)
);
ctx.subscriptions.push(
commandRunner(
'codeQLMockGitHubApiServer.cancelRecording',
'codeQL.mockGitHubApiServer.cancelRecording',
async () => await mockServer.cancelRecording(),
)
);

View File

@@ -60,7 +60,7 @@ export class MockGitHubApiServer extends DisposableObject {
this.recorder.start();
// Set a value in the context to track whether we are recording. This allows us to use this to show/hide commands (see package.json)
await commands.executeCommand('setContext', 'codeQLMockGitHubApiServer.recording', true);
await commands.executeCommand('setContext', 'codeQL.mockGitHubApiServer.recording', true);
await window.showInformationMessage('Recording scenario. To save the scenario, use the "CodeQL Mock GitHub API Server: Save Scenario" command.');
}
@@ -72,7 +72,7 @@ export class MockGitHubApiServer extends DisposableObject {
}
// Set a value in the context to track whether we are recording. This allows us to use this to show/hide commands (see package.json)
await commands.executeCommand('setContext', 'codeQLMockGitHubApiServer.recording', false);
await commands.executeCommand('setContext', 'codeQL.mockGitHubApiServer.recording', false);
if (!this.recorder.isRecording) {
void window.showErrorMessage('No scenario is currently being recorded.');
@@ -118,7 +118,7 @@ export class MockGitHubApiServer extends DisposableObject {
private async stopRecording(): Promise<void> {
// Set a value in the context to track whether we are recording. This allows us to use this to show/hide commands (see package.json)
await commands.executeCommand('setContext', 'codeQLMockGitHubApiServer.recording', false);
await commands.executeCommand('setContext', 'codeQL.mockGitHubApiServer.recording', false);
await this.recorder.stop();
await this.recorder.clear();

View File

@@ -27,9 +27,6 @@ describe('commands declared in package.json', function() {
const scopedCmds: Set<string> = new Set<string>();
const commandTitles: { [cmd: string]: string } = {};
// These are commands which are only used for testing/development
const testCmds = new Set<string>();
commands.forEach((commandDecl: CmdDecl) => {
const { command, title } = commandDecl;
if (
@@ -51,13 +48,6 @@ describe('commands declared in package.json', function() {
expect(title).not.to.be.undefined;
commandTitles[command] = title!;
}
else if (
command.match(/^codeQLMockGitHubApiServer\./)
) {
testCmds.add(command);
expect(title).not.to.be.undefined;
commandTitles[command] = title!;
}
else {
expect.fail(`Unexpected command name ${command}`);
}
@@ -92,11 +82,6 @@ describe('commands declared in package.json', function() {
scopedCmds.forEach(command => {
expect(commandTitles[command], `command ${command} should not be prefixed with 'CodeQL: ', since it is accessible from an extension-controlled context`).not.to.match(/^CodeQL: /);
});
testCmds.forEach(command => {
expect(commandTitles[command], `command ${command} should be prefixed with 'CodeQL ', since it is a testing/development command`).to.match(/^CodeQL /);
expect(commandTitles[command], `command ${command} should not be prefixed with 'CodeQL: ', since it is a testing/development command`).not.to.match(/^CodeQL: /);
});
});
it('should have the right commands accessible from the command palette', function() {
@@ -104,10 +89,6 @@ describe('commands declared in package.json', function() {
expect(disabledInPalette.has(command), `command ${command} should be enabled in the command palette`).to.be.false;
});
testCmds.forEach(command => {
expect(disabledInPalette.has(command), `command ${command} should be enabled in the command palette`).to.be.false;
});
// Commands in contribContextMenuCmds may reasonbly be enabled or
// disabled in the command palette; for example, codeQL.runQuery
// is available there, since we heuristically figure out which