@@ -171,7 +171,6 @@ export interface Client {
171171updateCustomConfigurations ( requestingProvider ?:CustomConfigurationProvider1 ) :Thenable < void > ;
172172updateCustomBrowseConfiguration ( requestingProvider ?:CustomConfigurationProvider1 ) :Thenable < void > ;
173173provideCustomConfiguration ( document :vscode . TextDocument ) :Promise < void > ;
174- getCustomConfigurationProviderId ( ) :Thenable < string | undefined > ;
175174getCurrentConfigName ( ) :Thenable < string > ;
176175takeOwnership ( document :vscode . TextDocument ) :void ;
177176queueTask < T > ( task :( ) => Thenable < T > ) :Thenable < T > ;
@@ -523,6 +522,7 @@ class DefaultClient implements Client {
523522
524523public updateCustomBrowseConfiguration ( requestingProvider ?:CustomConfigurationProvider1 ) :Thenable < void > {
525524return this . notifyWhenReady ( ( ) => {
525+ console . log ( "updateCustomBrowseConfiguration" ) ;
526526if ( ! this . configurationProvider ) {
527527return ;
528528}
@@ -536,6 +536,9 @@ class DefaultClient implements Client {
536536if ( await currentProvider . canProvideBrowseConfiguration ( tokenSource . token ) ) {
537537return currentProvider . provideBrowseConfiguration ( tokenSource . token ) ;
538538}
539+ if ( currentProvider . version >= Version . v2 ) {
540+ console . warn ( "failed to provide browse configuration" ) ;
541+ }
539542return Promise . reject ( "" ) ;
540543} ;
541544this . queueTaskWithTimeout ( task , configProviderTimeout , tokenSource ) . then (
@@ -550,7 +553,7 @@ class DefaultClient implements Client {
550553public async provideCustomConfiguration ( document :vscode . TextDocument ) :Promise < void > {
551554let tokenSource :CancellationTokenSource = new CancellationTokenSource ( ) ;
552555let providers :CustomConfigurationProviderCollection = getCustomConfigProviders ( ) ;
553-
556+ console . log ( "provideCustomConfiguration" ) ;
554557if ( providers . size === 0 ) {
555558return Promise . resolve ( ) ;
556559}
@@ -578,6 +581,7 @@ class DefaultClient implements Client {
578581}
579582} catch ( err ) {
580583}
584+ console . warn ( "failed to provide configuration" ) ;
581585return Promise . reject ( "" ) ;
582586} ;
583587
@@ -617,7 +621,7 @@ class DefaultClient implements Client {
617621return util . isHeader ( document ) && ! document . uri . toString ( ) . startsWith ( this . RootUri . toString ( ) ) ;
618622}
619623
620- public getCustomConfigurationProviderId ( ) :Thenable < string | undefined > {
624+ private getCustomConfigurationProviderId ( ) :Thenable < string | undefined > {
621625return this . queueTask ( ( ) => Promise . resolve ( this . configuration . CurrentConfigurationProvider ) ) ;
622626}
623627
@@ -651,22 +655,27 @@ class DefaultClient implements Client {
651655
652656public queueTask ( task :( ) => Thenable < any > ) :Thenable < any > {
653657if ( this . isSupported ) {
654- this . pendingRequests ++ ;
655- let nextTask :( ) => Thenable < any > = ( ) => {
656- let result :Thenable < any > = task ( ) ;
657- this . pendingRequests -- ;
658- if ( this . pendingRequests === 0 ) {
659- this . pendingTask = null ;
658+ let nextTask :( ) => Thenable < any > = async ( ) => {
659+ try {
660+ let result :any = await task ( ) ;
661+ this . pendingRequests -- ;
662+ return result ;
663+ } catch ( err ) {
664+ console . error ( err ) ;
665+ this . pendingRequests -- ;
666+ throw err ;
660667}
661- return result ;
662668} ;
663-
664- if ( this . pendingTask ) {
665- // We don't want the queue to stall because of a rejected promise.
666- return this . pendingTask . then ( nextTask , nextTask ) ;
667- } else {
669+
670+ console . assert ( this . pendingRequests >= 0 ) ;
671+ if ( this . pendingRequests === 0 ) {
672+ this . pendingRequests ++ ;
668673this . pendingTask = nextTask ( ) ;
669674return this . pendingTask ;
675+ } else {
676+ // We don't want the queue to stall because of a rejected promise.
677+ this . pendingRequests ++ ;
678+ return this . pendingTask . then ( nextTask , nextTask ) ;
670679}
671680} else {
672681return Promise . reject ( "Unsupported client" ) ;
@@ -1111,15 +1120,29 @@ class DefaultClient implements Client {
11111120public sendCustomConfigurations ( configs :any ) :void {
11121121// configs is marked as 'any' because it is untrusted data coming from a 3rd-party. We need to sanitize it before sending it to the language server.
11131122if ( ! configs || ! ( configs instanceof Array ) ) {
1123+ console . warn ( "discarding invalid SourceFileConfigurationItems[]: " + configs ) ;
11141124return ;
11151125}
1126+
1127+ let settings :CppSettings = new CppSettings ( this . RootUri ) ;
1128+ let out :logger . Logger = logger . getOutputChannelLogger ( ) ;
1129+ if ( settings . loggingLevel === "Debug" ) {
1130+ out . appendLine ( "Custom configurations received:" ) ;
1131+ }
11161132let sanitized :SourceFileConfigurationItemAdapter [ ] = [ ] ;
11171133configs . forEach ( item => {
11181134if ( this . isSourceFileConfigurationItem ( item ) ) {
11191135sanitized . push ( {
11201136uri :item . uri . toString ( ) ,
11211137configuration :item . configuration
11221138} ) ;
1139+ if ( settings . loggingLevel === "Debug" ) {
1140+ out . appendLine ( ` uri:${ item . uri . toString ( ) } ` ) ;
1141+ out . appendLine ( ` config:${ JSON . stringify ( item . configuration , null , 2 ) } ` ) ;
1142+ }
1143+ if ( item . configuration . includePath . some ( path => path . endsWith ( '**' ) ) ) {
1144+ console . warn ( "custom include paths should not use recursive includes ('**')" ) ;
1145+ }
11231146} else {
11241147console . warn ( "discarding invalid SourceFileConfigurationItem: " + item ) ;
11251148}
@@ -1138,6 +1161,7 @@ class DefaultClient implements Client {
11381161public sendCustomBrowseConfiguration ( config :any ) :Thenable < void > {
11391162// config is marked as 'any' because it is untrusted data coming from a 3rd-party. We need to sanitize it before sending it to the language server.
11401163if ( ! config || config instanceof Array ) {
1164+ console . warn ( "discarding invalid WorkspaceBrowseConfiguration: " + config ) ;
11411165return Promise . resolve ( ) ;
11421166}
11431167let sanitized :WorkspaceBrowseConfiguration = < WorkspaceBrowseConfiguration > config ;
@@ -1147,6 +1171,12 @@ class DefaultClient implements Client {
11471171return Promise . resolve ( ) ;
11481172}
11491173
1174+ let settings :CppSettings = new CppSettings ( this . RootUri ) ;
1175+ let out :logger . Logger = logger . getOutputChannelLogger ( ) ;
1176+ if ( settings . loggingLevel === "Debug" ) {
1177+ out . appendLine ( `Custom browse configuration received:${ JSON . stringify ( sanitized , null , 2 ) } ` ) ;
1178+ }
1179+
11501180let params :CustomBrowseConfigurationParams = {
11511181browseConfiguration :sanitized
11521182} ;
@@ -1274,7 +1304,6 @@ class NullClient implements Client {
12741304updateCustomConfigurations ( requestingProvider ?:CustomConfigurationProvider1 ) :Thenable < void > { return Promise . resolve ( ) ; }
12751305updateCustomBrowseConfiguration ( requestingProvider ?:CustomConfigurationProvider1 ) :Thenable < void > { return Promise . resolve ( ) ; }
12761306provideCustomConfiguration ( document :vscode . TextDocument ) :Promise < void > { return Promise . resolve ( ) ; }
1277- getCustomConfigurationProviderId ( ) :Thenable < string | undefined > { return Promise . resolve ( undefined ) ; }
12781307getCurrentConfigName ( ) :Thenable < string > { return Promise . resolve ( "" ) ; }
12791308takeOwnership ( document :vscode . TextDocument ) :void { }
12801309queueTask < T > ( task :( ) => Thenable < T > ) :Thenable < T > { return task ( ) ; }