forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmockWorkspaceConfig.ts
More file actions
61 lines (53 loc) · 1.87 KB
/
mockWorkspaceConfig.ts
File metadata and controls
61 lines (53 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import { ConfigurationTarget, WorkspaceConfiguration } from 'vscode';
export class MockWorkspaceConfiguration implements WorkspaceConfiguration {
// tslint:disable: no-any
private values = new Map<string, any>();
constructor(defaultSettings?: any) {
if (defaultSettings) {
const keys = [...Object.keys(defaultSettings)];
keys.forEach((k) => this.values.set(k, defaultSettings[k]));
}
// Special case python path (not in the object)
if (defaultSettings && defaultSettings.pythonPath) {
this.values.set('pythonPath', defaultSettings.pythonPath);
}
// Special case datascience. Not the same case
if (defaultSettings && defaultSettings.datascience) {
this.values.set('dataScience', defaultSettings.datascience);
}
}
public get<T>(key: string, defaultValue?: T): T | undefined {
// tslint:disable-next-line: use-named-parameter
if (this.values.has(key)) {
return this.values.get(key);
}
return arguments.length > 1 ? defaultValue : (undefined as any);
}
public has(section: string): boolean {
return this.values.has(section);
}
public inspect<T>(
_section: string
):
| {
key: string;
defaultValue?: T | undefined;
globalValue?: T | undefined;
workspaceValue?: T | undefined;
workspaceFolderValue?: T | undefined;
}
| undefined {
return;
}
public update(
section: string,
value: any,
_configurationTarget?: boolean | ConfigurationTarget | undefined
): Promise<void> {
this.values.set(section, value);
return Promise.resolve();
}
}