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

Function getLaunchConfigDefaultTemplate

src/shared/vscode/debugger.ts:13–32  ·  view source on GitHub ↗
(documentUri: Uri, debug: boolean)

Source from the content-addressed store, hash-verified

11/// Tries to get the most specific config first (eg. using an explicit `noDebug` flag) and otherwise falls back to
12/// a generic (no `noDebug` specified) one, injecting the value of `debug` inverted as `noDebug`.
13export function getLaunchConfigDefaultTemplate(documentUri: Uri, debug: boolean): TemplatedLaunchConfig | undefined {
14 const runConfigs: TemplatedLaunchConfig[] = workspace.getConfiguration("launch", documentUri).get<any[]>("configurations") || [];
15 const filePath = fsPath(documentUri);
16 const workspaceUri = workspace.getWorkspaceFolder(documentUri)?.uri;
17 const workspacePath = workspaceUri ? fsPath(workspaceUri) : undefined;
18
19 const validConfigs = runConfigs.filter((c) => c.type === "dart"
20 && c.templateFor !== undefined && c.templateFor !== null
21 && workspacePath ? isWithinPathOrEqual(filePath, path.join(workspacePath, c.templateFor)) : false
22 );
23
24 const requiredNoDebugValue = !debug;
25 const bestConfig =
26 // Try specific config first.
27 validConfigs.find((c) => c.noDebug === requiredNoDebugValue)
28 // Otherwise, look for one that doesn't specify noDebug.
29 ?? validConfigs.find((c) => c.noDebug === undefined);
30
31 return bestConfig ? { ...bestConfig, noDebug: requiredNoDebugValue } : undefined;
32}
33
34export function getTemplatedLaunchConfigs(documentUri: Uri, fileType: string): TemplatedLaunchConfig[] {
35 const runConfigs: TemplatedLaunchConfig[] = workspace.getConfiguration("launch", documentUri).get<any[]>("configurations") || [];

Callers 3

runTestsMethod · 0.90
constructorMethod · 0.90

Calls 3

fsPathFunction · 0.90
isWithinPathOrEqualFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected