@@ -118,27 +118,8 @@ interface QueryTranslationUnitSourceParams {
118118uri :string ;
119119}
120120
121- export enum QueryTranslationUnitSourceConfigDisposition {
122-
123- /**
124- * No custom config needed for this file
125- */
126- ConfigNotNeeded = 0 ,
127-
128- /**
129- * Custom config is needed for this file
130- */
131- ConfigNeeded = 1 ,
132-
133- /**
134- * Custom config is needed for the ancestor file returned in uri
135- */
136- AncestorConfigNeeded = 2
137- }
138-
139121interface QueryTranslationUnitSourceResult {
140- uri :string ;
141- configDisposition :QueryTranslationUnitSourceConfigDisposition ;
122+ candidates :string [ ] ;
142123}
143124
144125interface GetDiagnosticsResult {
@@ -1192,6 +1173,7 @@ export class DefaultClient implements Client {
11921173
11931174public updateCustomConfigurations ( requestingProvider ?:CustomConfigurationProvider1 ) :Thenable < void > {
11941175return this . notifyWhenReady ( ( ) => {
1176+ this . clearCustomConfigurations ( ) ;
11951177if ( ! this . configurationProvider ) {
11961178return ;
11971179}
@@ -1309,7 +1291,7 @@ export class DefaultClient implements Client {
13091291return Promise . resolve ( ) ;
13101292}
13111293console . log ( "provideCustomConfiguration" ) ;
1312- let providerId :string | undefined = this . configuration . CurrentConfigurationProvider ;
1294+ let providerId :string | undefined = this . configuration . CurrentConfigurationProvider ;
13131295if ( ! providerId ) {
13141296onFinished ( ) ;
13151297return Promise . resolve ( ) ;
@@ -1320,43 +1302,48 @@ export class DefaultClient implements Client {
13201302uri :docUri . toString ( )
13211303} ;
13221304let response :QueryTranslationUnitSourceResult = await this . languageClient . sendRequest ( QueryTranslationUnitSourceRequest , params ) ;
1323- if ( response . configDisposition === QueryTranslationUnitSourceConfigDisposition . ConfigNotNeeded ) {
1305+ if ( ! response . candidates || response . candidates . length === 0 ) {
1306+ // If we didn't receive any candidates, no configuration is needed.
13241307onFinished ( ) ;
13251308return Promise . resolve ( ) ;
13261309}
13271310
1328- let tuUri :vscode . Uri = vscode . Uri . parse ( response . uri ) ;
1329- let configName :string = this . configuration . CurrentConfiguration . name ;
13301311const notReadyMessage :string = `${ providerName } is not ready` ;
1331- let provideConfigurationAsync :( ) => Thenable < SourceFileConfigurationItem [ ] > = async ( ) => {
1332- // The config requests that we use a provider, try to get IntelliSense configuration info from that provider.
1333- try {
1334- let provider :CustomConfigurationProvider1 | null = providers . get ( providerId ) ;
1335- if ( provider ) {
1336- if ( ! provider . isReady ) {
1337- return Promise . reject ( notReadyMessage ) ;
1338- }
1312+ let provider :CustomConfigurationProvider1 | null = providers . get ( providerId ) ;
1313+ if ( provider ) {
1314+ if ( ! provider . isReady ) {
1315+ return Promise . reject ( notReadyMessage ) ;
1316+ }
1317+ providerName = provider . name ;
1318+ }
13391319
1340- providerName = provider . name ;
1341- if ( await provider . canProvideConfiguration ( tuUri , tokenSource . token ) ) {
1342- return provider . provideConfigurations ( [ tuUri ] , tokenSource . token ) ;
1320+ // Need to loop through candidates, to see if we can get a custom configuration from any of them.
1321+ // Wrap all lookups in a single task, so we can apply a timeout to the entire duration.
1322+ let provideConfigurationAsync :( ) => Thenable < SourceFileConfigurationItem [ ] > = async ( ) => {
1323+ if ( provider ) {
1324+ for ( let i :number = 0 ; i < response . candidates . length ; ++ i ) {
1325+ try {
1326+ let candidate :string = response . candidates [ i ] ;
1327+ let tuUri :vscode . Uri = vscode . Uri . parse ( candidate ) ;
1328+ if ( await provider . canProvideConfiguration ( tuUri , tokenSource . token ) ) {
1329+ let configs :SourceFileConfigurationItem [ ] = await provider . provideConfigurations ( [ tuUri ] , tokenSource . token ) ;
1330+ if ( configs && configs . length > 0 && configs [ 0 ] ) {
1331+ return configs ;
1332+ }
1333+ }
1334+ if ( tokenSource . token . isCancellationRequested ) {
1335+ return null ;
1336+ }
1337+ } catch ( err ) {
1338+ console . warn ( "Caught exception request configuration" ) ;
13431339}
13441340}
1345- } catch ( err ) {
13461341}
1347- console . warn ( "failed to provide configuration" ) ;
1348- return Promise . reject ( "" ) ;
13491342} ;
1350-
13511343return this . callTaskWithTimeout ( provideConfigurationAsync , configProviderTimeout , tokenSource ) . then (
13521344( configs :SourceFileConfigurationItem [ ] ) => {
13531345if ( configs && configs . length > 0 ) {
13541346this . sendCustomConfigurations ( configs , false ) ;
1355- if ( response . configDisposition === QueryTranslationUnitSourceConfigDisposition . AncestorConfigNeeded ) {
1356- // replacing uri with original uri
1357- let newConfig :SourceFileConfigurationItem = { uri :docUri , configuration :configs [ 0 ] . configuration } ;
1358- this . sendCustomConfigurations ( [ newConfig ] , false ) ;
1359- }
13601347}
13611348onFinished ( ) ;
13621349} ,
@@ -1372,6 +1359,7 @@ export class DefaultClient implements Client {
13721359if ( settings . configurationWarnings === "Enabled" && ! this . isExternalHeader ( docUri ) && ! vscode . debug . activeDebugSession ) {
13731360const dismiss :string = localize ( "dismiss.button" , "Dismiss" ) ;
13741361const disable :string = localize ( "diable.warnings.button" , "Disable Warnings" ) ;
1362+ let configName :string = this . configuration . CurrentConfiguration . name ;
13751363let message :string = localize ( "unable.to.provide.configuraiton" ,
13761364"{0} is unable to provide IntelliSense configuration information for '{1}'. Settings from the '{2}' configuration will be used instead." ,
13771365providerName , docUri . fsPath , configName ) ;
@@ -1981,9 +1969,6 @@ export class DefaultClient implements Client {
19811969} ) . then ( ( ) => {
19821970let newProvider :string = this . configuration . CurrentConfigurationProvider ;
19831971if ( this . configurationProvider !== newProvider ) {
1984- if ( this . configurationProvider ) {
1985- this . clearCustomConfigurations ( ) ;
1986- }
19871972this . configurationProvider = newProvider ;
19881973this . updateCustomConfigurations ( ) ;
19891974this . updateCustomBrowseConfiguration ( ) ;