Skip to content

Commit fe29a1a

Browse files
committed
Add more comments
1 parent 3323fd4 commit fe29a1a

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

extensions/ql-vscode/src/data-extensions-editor/extension-pack-picker.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,13 @@ async function autoCreateExtensionPack(
318318
extensionPacksInfo: QlpacksInfo,
319319
logger: NotificationLogger,
320320
): Promise<ExtensionPack | undefined> {
321+
// Choose a workspace folder to create the extension pack in
321322
const workspaceFolder = await autoPickWorkspaceFolder(language);
322323
if (!workspaceFolder) {
323324
return undefined;
324325
}
325326

327+
// Generate the name of the extension pack
326328
const packName = autoNameExtensionPack(name, language);
327329
if (!packName) {
328330
void showAndLogErrorMessage(
@@ -333,8 +335,10 @@ async function autoCreateExtensionPack(
333335
return undefined;
334336
}
335337

338+
// Find any existing locations of this extension pack
336339
const existingExtensionPackPaths =
337340
extensionPacksInfo[formatPackName(packName)];
341+
338342
// If there is already an extension pack with this name, use it if it is valid
339343
if (existingExtensionPackPaths?.length === 1) {
340344
let extensionPack: ExtensionPack;
@@ -396,23 +400,29 @@ async function autoPickWorkspaceFolder(
396400
): Promise<WorkspaceFolder | undefined> {
397401
const workspaceFolders = getOnDiskWorkspaceFoldersObjects();
398402

403+
// If there's only 1 workspace folder, use that
399404
if (workspaceFolders.length === 1) {
400405
return workspaceFolders[0];
401406
}
407+
408+
// In the vscode-codeql-starter repository, all workspace folders are named "codeql-custom-queries-<language>",
409+
// so we can use that to find the workspace folder for the language
402410
const starterWorkspaceFolderForLanguage = workspaceFolders.find(
403411
(folder) => folder.name === `codeql-custom-queries-${language}`,
404412
);
405413
if (starterWorkspaceFolderForLanguage) {
406414
return starterWorkspaceFolderForLanguage;
407415
}
408416

417+
// Otherwise, try to find one that ends with "-<language>"
409418
const workspaceFolderForLanguage = workspaceFolders.find((folder) =>
410419
folder.name.endsWith(`-${language}`),
411420
);
412421
if (workspaceFolderForLanguage) {
413422
return workspaceFolderForLanguage;
414423
}
415424

425+
// If we can't find one, just ask the user
416426
return askForWorkspaceFolder();
417427
}
418428

0 commit comments

Comments
 (0)