(documentUri: Uri, debug: boolean)
| 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`. |
| 13 | export 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 | |
| 34 | export function getTemplatedLaunchConfigs(documentUri: Uri, fileType: string): TemplatedLaunchConfig[] { |
| 35 | const runConfigs: TemplatedLaunchConfig[] = workspace.getConfiguration("launch", documentUri).get<any[]>("configurations") || []; |
no test coverage detected