@@ -58,11 +58,15 @@ export class AbstractVariableResolverService implements IConfigurationResolverSe
58
58
}
59
59
}
60
60
61
+ public resolveWithEnvironment ( environment : IProcessEnvironment , root : IWorkspaceFolder | undefined , value : string ) : string {
62
+ return this . recursiveResolve ( environment , root ? root . uri : undefined , value ) ;
63
+ }
64
+
61
65
public async resolveAsync ( root : IWorkspaceFolder | undefined , value : string ) : Promise < string > ;
62
66
public async resolveAsync ( root : IWorkspaceFolder | undefined , value : string [ ] ) : Promise < string [ ] > ;
63
67
public async resolveAsync ( root : IWorkspaceFolder | undefined , value : IStringDictionary < string > ) : Promise < IStringDictionary < string > > ;
64
68
public async resolveAsync ( root : IWorkspaceFolder | undefined , value : any ) : Promise < any > {
65
- return this . recursiveResolve ( root ? root . uri : undefined , value ) ;
69
+ return this . recursiveResolve ( this . _envVariables , root ? root . uri : undefined , value ) ;
66
70
}
67
71
68
72
/**
@@ -72,7 +76,7 @@ export class AbstractVariableResolverService implements IConfigurationResolverSe
72
76
public resolve ( root : IWorkspaceFolder | undefined , value : string [ ] ) : string [ ] ;
73
77
public resolve ( root : IWorkspaceFolder | undefined , value : IStringDictionary < string > ) : IStringDictionary < string > ;
74
78
public resolve ( root : IWorkspaceFolder | undefined , value : any ) : any {
75
- return this . recursiveResolve ( root ? root . uri : undefined , value ) ;
79
+ return this . recursiveResolve ( this . _envVariables , root ? root . uri : undefined , value ) ;
76
80
}
77
81
78
82
/**
@@ -97,7 +101,7 @@ export class AbstractVariableResolverService implements IConfigurationResolverSe
97
101
delete result . linux ;
98
102
99
103
// substitute all variables recursively in string values
100
- return this . recursiveResolve ( workspaceFolder ? workspaceFolder . uri : undefined , result , commandValueMapping , resolvedVariables ) ;
104
+ return this . recursiveResolve ( this . _envVariables , workspaceFolder ? workspaceFolder . uri : undefined , result , commandValueMapping , resolvedVariables ) ;
101
105
}
102
106
103
107
public resolveAny ( workspaceFolder : IWorkspaceFolder | undefined , config : any , commandValueMapping ?: IStringDictionary < string > ) : any {
@@ -130,23 +134,23 @@ export class AbstractVariableResolverService implements IConfigurationResolverSe
130
134
}
131
135
}
132
136
133
- private recursiveResolve ( folderUri : uri | undefined , value : any , commandValueMapping ?: IStringDictionary < string > , resolvedVariables ?: Map < string , string > ) : any {
137
+ private recursiveResolve ( environment : IProcessEnvironment | undefined , folderUri : uri | undefined , value : any , commandValueMapping ?: IStringDictionary < string > , resolvedVariables ?: Map < string , string > ) : any {
134
138
if ( types . isString ( value ) ) {
135
- return this . resolveString ( folderUri , value , commandValueMapping , resolvedVariables ) ;
139
+ return this . resolveString ( environment , folderUri , value , commandValueMapping , resolvedVariables ) ;
136
140
} else if ( types . isArray ( value ) ) {
137
- return value . map ( s => this . recursiveResolve ( folderUri , s , commandValueMapping , resolvedVariables ) ) ;
141
+ return value . map ( s => this . recursiveResolve ( environment , folderUri , s , commandValueMapping , resolvedVariables ) ) ;
138
142
} else if ( types . isObject ( value ) ) {
139
143
let result : IStringDictionary < string | IStringDictionary < string > | string [ ] > = Object . create ( null ) ;
140
144
Object . keys ( value ) . forEach ( key => {
141
- const replaced = this . resolveString ( folderUri , key , commandValueMapping , resolvedVariables ) ;
142
- result [ replaced ] = this . recursiveResolve ( folderUri , value [ key ] , commandValueMapping , resolvedVariables ) ;
145
+ const replaced = this . resolveString ( environment , folderUri , key , commandValueMapping , resolvedVariables ) ;
146
+ result [ replaced ] = this . recursiveResolve ( environment , folderUri , value [ key ] , commandValueMapping , resolvedVariables ) ;
143
147
} ) ;
144
148
return result ;
145
149
}
146
150
return value ;
147
151
}
148
152
149
- private resolveString ( folderUri : uri | undefined , value : string , commandValueMapping : IStringDictionary < string > | undefined , resolvedVariables ?: Map < string , string > ) : string {
153
+ private resolveString ( environment : IProcessEnvironment | undefined , folderUri : uri | undefined , value : string , commandValueMapping : IStringDictionary < string > | undefined , resolvedVariables ?: Map < string , string > ) : string {
150
154
151
155
// loop through all variables occurrences in 'value'
152
156
const replaced = value . replace ( AbstractVariableResolverService . VARIABLE_REGEXP , ( match : string , variable : string ) => {
@@ -155,7 +159,7 @@ export class AbstractVariableResolverService implements IConfigurationResolverSe
155
159
return match ;
156
160
}
157
161
158
- let resolvedValue = this . evaluateSingleVariable ( match , variable , folderUri , commandValueMapping ) ;
162
+ let resolvedValue = this . evaluateSingleVariable ( environment , match , variable , folderUri , commandValueMapping ) ;
159
163
160
164
if ( resolvedVariables ) {
161
165
resolvedVariables . set ( variable , resolvedValue ) ;
@@ -171,7 +175,7 @@ export class AbstractVariableResolverService implements IConfigurationResolverSe
171
175
return this . _labelService ? this . _labelService . getUriLabel ( displayUri , { noPrefix : true } ) : displayUri . fsPath ;
172
176
}
173
177
174
- private evaluateSingleVariable ( match : string , variable : string , folderUri : uri | undefined , commandValueMapping : IStringDictionary < string > | undefined ) : string {
178
+ private evaluateSingleVariable ( environment : IProcessEnvironment | undefined , match : string , variable : string , folderUri : uri | undefined , commandValueMapping : IStringDictionary < string > | undefined ) : string {
175
179
176
180
// try to separate variable arguments from variable name
177
181
let argument : string | undefined ;
@@ -230,8 +234,8 @@ export class AbstractVariableResolverService implements IConfigurationResolverSe
230
234
231
235
case 'env' :
232
236
if ( argument ) {
233
- if ( this . _envVariables ) {
234
- const env = this . _envVariables [ isWindows ? argument . toLowerCase ( ) : argument ] ;
237
+ if ( environment ) {
238
+ const env = environment [ isWindows ? argument . toLowerCase ( ) : argument ] ;
235
239
if ( types . isString ( env ) ) {
236
240
return env ;
237
241
}
0 commit comments