Scope mock commands
The command lint expects all command palette commands to have a common prefix which these violated. So, I've moved them to being a scoped command so we can have different lints.
This commit is contained in:
@@ -647,15 +647,15 @@
|
||||
"enablement": "codeql.hasQLSource"
|
||||
},
|
||||
{
|
||||
"command": "codeQL.mockGitHubApiServer.startRecording",
|
||||
"command": "codeQLMockGitHubApiServer.startRecording",
|
||||
"title": "CodeQL Mock GitHub API Server: Start Scenario Recording"
|
||||
},
|
||||
{
|
||||
"command": "codeQL.mockGitHubApiServer.saveScenario",
|
||||
"command": "codeQLMockGitHubApiServer.saveScenario",
|
||||
"title": "CodeQL Mock GitHub API Server: Save Scenario"
|
||||
},
|
||||
{
|
||||
"command": "codeQL.mockGitHubApiServer.cancelRecording",
|
||||
"command": "codeQLMockGitHubApiServer.cancelRecording",
|
||||
"title": "CodeQL Mock GitHub API Server: Cancel Scenario"
|
||||
}
|
||||
],
|
||||
@@ -1118,16 +1118,16 @@
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "codeQL.mockGitHubApiServer.startRecording",
|
||||
"when": "config.codeQL.variantAnalysis.mockGitHubApiServer && !codeQL.mockGitHubApiServer.recording"
|
||||
"command": "codeQLMockGitHubApiServer.startRecording",
|
||||
"when": "config.codeQL.variantAnalysis.mockGitHubApiServer && !codeQLMockGitHubApiServer.recording"
|
||||
},
|
||||
{
|
||||
"command": "codeQL.mockGitHubApiServer.saveScenario",
|
||||
"when": "codeQL.mockGitHubApiServer.recording"
|
||||
"command": "codeQLMockGitHubApiServer.saveScenario",
|
||||
"when": "codeQLMockGitHubApiServer.recording"
|
||||
},
|
||||
{
|
||||
"command": "codeQL.mockGitHubApiServer.cancelRecording",
|
||||
"when": "codeQL.mockGitHubApiServer.recording"
|
||||
"command": "codeQLMockGitHubApiServer.cancelRecording",
|
||||
"when": "codeQLMockGitHubApiServer.recording"
|
||||
}
|
||||
],
|
||||
"editor/context": [
|
||||
|
||||
@@ -1195,19 +1195,19 @@ async function activateWithInstalledDistribution(
|
||||
ctx.subscriptions.push(mockServer);
|
||||
ctx.subscriptions.push(
|
||||
commandRunner(
|
||||
'codeQL.mockGitHubApiServer.startRecording',
|
||||
'codeQLMockGitHubApiServer.startRecording',
|
||||
async () => await mockServer.recordScenario(),
|
||||
)
|
||||
);
|
||||
ctx.subscriptions.push(
|
||||
commandRunner(
|
||||
'codeQL.mockGitHubApiServer.saveScenario',
|
||||
'codeQLMockGitHubApiServer.saveScenario',
|
||||
async () => await mockServer.saveScenario(),
|
||||
)
|
||||
);
|
||||
ctx.subscriptions.push(
|
||||
commandRunner(
|
||||
'codeQL.mockGitHubApiServer.cancelRecording',
|
||||
'codeQLMockGitHubApiServer.cancelRecording',
|
||||
async () => await mockServer.cancelRecording(),
|
||||
)
|
||||
);
|
||||
|
||||
@@ -56,7 +56,7 @@ export class MockGitHubApiServer extends DisposableObject {
|
||||
}
|
||||
|
||||
this.recorder.start();
|
||||
await commands.executeCommand('setContext', 'codeQL.mockGitHubApiServer.recording', true);
|
||||
await commands.executeCommand('setContext', 'codeQLMockGitHubApiServer.recording', true);
|
||||
|
||||
await window.showInformationMessage('Recording scenario. To save the scenario, use the "CodeQL Mock GitHub API Server: Save Scenario" command.');
|
||||
}
|
||||
@@ -67,7 +67,7 @@ export class MockGitHubApiServer extends DisposableObject {
|
||||
return;
|
||||
}
|
||||
|
||||
await commands.executeCommand('setContext', 'codeQL.mockGitHubApiServer.recording', false);
|
||||
await commands.executeCommand('setContext', 'codeQLMockGitHubApiServer.recording', false);
|
||||
|
||||
if (!this.recorder.isRecording) {
|
||||
void window.showErrorMessage('No scenario is currently being recorded.');
|
||||
@@ -112,7 +112,7 @@ export class MockGitHubApiServer extends DisposableObject {
|
||||
}
|
||||
|
||||
private async stopRecording(): Promise<void> {
|
||||
await commands.executeCommand('setContext', 'codeQL.mockGitHubApiServer.recording', false);
|
||||
await commands.executeCommand('setContext', 'codeQLMockGitHubApiServer.recording', false);
|
||||
|
||||
await this.recorder.stop();
|
||||
await this.recorder.clear();
|
||||
|
||||
@@ -27,6 +27,9 @@ 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 (
|
||||
@@ -48,6 +51,13 @@ 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}`);
|
||||
}
|
||||
@@ -82,6 +92,11 @@ 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() {
|
||||
@@ -89,6 +104,10 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user