11import { ConfigurationChangeEvent , workspace } from 'vscode' ;
2- import { Config } from './Config' ;
32import { IDisposable } from './types' ;
3+ import { VSCodeConfig } from './VSCodeConfig' ;
4+ import { WorkspaceConfig } from './WorkspaceConfig' ;
45
56export class ConfigService implements IDisposable {
6- private static readonly _namespace = 'oxc' ;
7+ public static readonly namespace = 'oxc' ;
78 private readonly _disposables : IDisposable [ ] = [ ] ;
89
9- public config : Config ;
10+ public vsCodeConfig : VSCodeConfig ;
11+
12+ private _workspaceConfig : WorkspaceConfig ;
1013
1114 public onConfigChange :
1215 | ( ( this : ConfigService , config : ConfigurationChangeEvent ) => Promise < void > )
1316 | undefined ;
1417
1518 constructor ( ) {
16- this . config = new Config ( ) ;
19+ const conf = workspace . getConfiguration ( ConfigService . namespace ) ;
20+ this . vsCodeConfig = new VSCodeConfig ( conf ) ;
21+ this . _workspaceConfig = new WorkspaceConfig ( conf ) ;
1722 this . onConfigChange = undefined ;
1823
1924 const disposeChangeListener = workspace . onDidChangeConfiguration (
@@ -22,9 +27,19 @@ export class ConfigService implements IDisposable {
2227 this . _disposables . push ( disposeChangeListener ) ;
2328 }
2429
30+ public get rootServerConfig ( ) : WorkspaceConfig {
31+ return this . _workspaceConfig ;
32+ }
33+
34+ public refresh ( ) : void {
35+ const conf = workspace . getConfiguration ( ConfigService . namespace ) ;
36+ this . vsCodeConfig . refresh ( conf ) ;
37+ this . rootServerConfig . refresh ( conf ) ;
38+ }
39+
2540 private async onVscodeConfigChange ( event : ConfigurationChangeEvent ) : Promise < void > {
26- if ( event . affectsConfiguration ( ConfigService . _namespace ) ) {
27- this . config . refresh ( ) ;
41+ if ( event . affectsConfiguration ( ConfigService . namespace ) ) {
42+ this . refresh ( ) ;
2843 await this . onConfigChange ?.( event ) ;
2944 }
3045 }
0 commit comments