Skip to content

Commit 97e9129

Browse files
authored
Merge pull request #2334 from github/koesie10/data-extension-editor-language-check
Add database language check to data extensions editor
2 parents 1367d38 + 79c39a0 commit 97e9129

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

extensions/ql-vscode/src/data-extensions-editor/data-extensions-editor-module.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { showAndLogErrorMessage } from "../helpers";
1111
import { withProgress } from "../progress";
1212
import { pickExtensionPackModelFile } from "./extension-pack-picker";
1313

14+
const SUPPORTED_LANGUAGES: string[] = ["java", "csharp"];
15+
1416
export class DataExtensionsEditorModule {
1517
private readonly queryStorageDir: string;
1618

@@ -51,15 +53,22 @@ export class DataExtensionsEditorModule {
5153

5254
public getCommands(): DataExtensionsEditorCommands {
5355
return {
54-
"codeQL.openDataExtensionsEditor": async () =>
55-
withProgress(
56-
async (progress, token) => {
57-
const db = this.databaseManager.currentDatabaseItem;
58-
if (!db) {
59-
void showAndLogErrorMessage("No database selected");
60-
return;
61-
}
56+
"codeQL.openDataExtensionsEditor": async () => {
57+
const db = this.databaseManager.currentDatabaseItem;
58+
if (!db) {
59+
void showAndLogErrorMessage("No database selected");
60+
return;
61+
}
62+
63+
if (!SUPPORTED_LANGUAGES.includes(db.language)) {
64+
void showAndLogErrorMessage(
65+
`The data extensions editor is not supported for ${db.language} databases.`,
66+
);
67+
return;
68+
}
6269

70+
return withProgress(
71+
async (progress, token) => {
6372
if (!(await this.cliServer.cliConstraints.supportsQlpacksKind())) {
6473
void showAndLogErrorMessage(
6574
`This feature requires CodeQL CLI version ${CliVersionConstraint.CLI_VERSION_WITH_QLPACKS_KIND.format()} or later.`,
@@ -92,7 +101,8 @@ export class DataExtensionsEditorModule {
92101
{
93102
title: "Opening Data Extensions Editor",
94103
},
95-
),
104+
);
105+
},
96106
};
97107
}
98108

0 commit comments

Comments
 (0)