1- import { ConfigurationTarget , workspace } from 'vscode' ;
2- import { CUSTOM_CODEQL_PATH_SETTING , REMOTE_CONTROLLER_REPO , REMOTE_REPO_LISTS , Setting } from '../config' ;
1+ import { ConfigurationTarget } from 'vscode' ;
2+ import { CUSTOM_CODEQL_PATH_SETTING , InspectionResult , REMOTE_CONTROLLER_REPO , REMOTE_REPO_LISTS , Setting } from '../config' ;
33
44class TestSetting < T > {
5- private settingState : {
6- globalValue ?: T ;
7- workspaceValue ?: T ,
8- workspaceFolderValue ?: T ,
9- } | undefined ;
5+ private settingState : InspectionResult < T > | undefined ;
106
117 constructor (
128 public readonly setting : Setting ,
139 private initialTestValue : T | undefined = undefined
1410 ) { }
1511
1612 public async get ( ) : Promise < T | undefined > {
17- return this . section . get ( this . setting . name ) ;
13+ return this . setting . getValue ( ) ;
1814 }
1915
2016 public async set ( value : T | undefined , target : ConfigurationTarget = ConfigurationTarget . Global ) : Promise < void > {
21- await this . section . update ( this . setting . name , value , target ) ;
17+ await this . setting . updateValue ( value , target ) ;
2218 }
2319
2420 public async setInitialTestValue ( value : T | undefined ) {
2521 this . initialTestValue = value ;
2622 }
2723
2824 public async initialSetup ( ) {
29- this . settingState = this . section . inspect ( this . setting . name ) ;
25+ this . settingState = this . setting . inspect ( ) ;
3026
3127 // Unfortunately it's not well-documented how to check whether we can write to a workspace
3228 // configuration. This is the best I could come up with. It only fails for initial test values
@@ -46,7 +42,7 @@ class TestSetting<T> {
4642 }
4743
4844 public async restoreToInitialValues ( ) {
49- const state = this . section . inspect ( this . setting . name ) ;
45+ const state = this . setting . inspect ( ) ;
5046
5147 // We need to check the state of the setting before we restore it. This is less important for the global
5248 // configuration target, but the workspace/workspace folder configuration might not even exist. If they
@@ -61,13 +57,6 @@ class TestSetting<T> {
6157 await this . set ( this . settingState ?. workspaceFolderValue , ConfigurationTarget . WorkspaceFolder ) ;
6258 }
6359 }
64-
65- private get section ( ) {
66- if ( this . setting . parent === undefined ) {
67- throw new Error ( 'Cannot get the value of a root setting.' ) ;
68- }
69- return workspace . getConfiguration ( this . setting . parent . qualifiedName ) ;
70- }
7160}
7261
7362export const testConfig = {
0 commit comments