MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / getProjectSelection

Function getProjectSelection

src/extension/utils/vscode/projects.ts:57–77  ·  view source on GitHub ↗
(logger: Logger, placeHolder: string)

Source from the content-addressed store, hash-verified

55}
56
57export async function getProjectSelection(logger: Logger, placeHolder: string): Promise<string[] | undefined> {
58 // Attempt to find a project based on the supplied folder of active file so we can pre-selected it.
59 const activeEditor = getActiveRealFileEditor();
60 const activeUri = activeEditor ? activeEditor.document.uri : undefined;
61 const activeFilePath = activeUri?.scheme === "file" ? fsPath(activeUri) : undefined;
62 const activeProjectFolder = activeFilePath ? locateBestProjectRoot(activeFilePath) : undefined;
63
64 // Find all possible projects.
65 const selectableProjectFolders = (await getAllProjectFolders(logger, getExcludedFolders, { requirePubspec: true, sort: true, searchDepth: config.projectSearchDepth }));
66 if (!selectableProjectFolders?.length) {
67 void vs.window.showWarningMessage(`No project roots were found. Does your project have a pubspec.yaml file?`);
68 return undefined;
69 }
70
71 if (selectableProjectFolders.length === 1) {
72 return selectableProjectFolders;
73 }
74
75 const prePickedFolders = activeProjectFolder ? new Set([activeProjectFolder]) : undefined;
76 return showFolderMultiPicker(selectableProjectFolders, prePickedFolders, placeHolder);
77}
78
79async function showPackagePicker(folders: PubWorkspaceOrPackageFolderInfo[], placeHolder: string): Promise<string | undefined> {
80 // No point asking the user if there's only one.

Callers 1

Calls 5

getActiveRealFileEditorFunction · 0.90
fsPathFunction · 0.90
locateBestProjectRootFunction · 0.90
getAllProjectFoldersFunction · 0.90
showFolderMultiPickerFunction · 0.85

Tested by

no test coverage detected