()
| 61 | }; |
| 62 | |
| 63 | export const getWorkspaceConfiguration = (): vscode.WorkspaceConfiguration => { |
| 64 | const values: { [key: string]: { globalValue: any; workspaceValue: any; workspaceFolderValue: any } } = {}; |
| 65 | |
| 66 | const configuration: vscode.WorkspaceConfiguration = { |
| 67 | get<T>(section: string, defaultValue?: T): T | undefined { |
| 68 | const result = values[section]; |
| 69 | if (result?.globalValue !== undefined) { |
| 70 | return result.globalValue; |
| 71 | } else if (result?.workspaceValue !== undefined) { |
| 72 | return result.workspaceValue; |
| 73 | } else if (result?.workspaceFolderValue !== undefined) { |
| 74 | return result.workspaceFolderValue; |
| 75 | } else { |
| 76 | return defaultValue; |
| 77 | } |
| 78 | }, |
| 79 | has: (section: string) => { |
| 80 | return values[section] !== undefined; |
| 81 | }, |
| 82 | inspect<T>( |
| 83 | section: string |
| 84 | ): |
| 85 | | { key: string; defaultValue?: T; globalValue?: T; workspaceValue?: T; workspaceFolderValue?: T } |
| 86 | | undefined { |
| 87 | const result = values[section]; |
| 88 | if (!result) { |
| 89 | return undefined; |
| 90 | } |
| 91 | return { |
| 92 | key: section, |
| 93 | globalValue: result.globalValue, |
| 94 | defaultValue: undefined, |
| 95 | workspaceValue: result.workspaceValue, |
| 96 | workspaceFolderValue: result.workspaceFolderValue, |
| 97 | }; |
| 98 | }, |
| 99 | update: async (section: string, value: any, _configurationTarget?: vscode.ConfigurationTarget | boolean) => { |
| 100 | const existing = values[section] ?? { |
| 101 | globalValue: undefined, |
| 102 | workspaceValue: undefined, |
| 103 | workspaceFolderValue: undefined, |
| 104 | }; |
| 105 | |
| 106 | switch (_configurationTarget) { |
| 107 | case vscode.ConfigurationTarget.Global: |
| 108 | existing.globalValue = value; |
| 109 | break; |
| 110 | case vscode.ConfigurationTarget.Workspace: |
| 111 | existing.workspaceValue = value; |
| 112 | break; |
| 113 | case vscode.ConfigurationTarget.WorkspaceFolder: |
| 114 | existing.workspaceFolderValue = value; |
| 115 | break; |
| 116 | case undefined: |
| 117 | existing.globalValue = value; |
| 118 | break; |
| 119 | } |
| 120 |
no outgoing calls
no test coverage detected