@@ -845,76 +845,76 @@ class ModelSemanticColoring extends Disposable {
845845 private _isDisposed : boolean ;
846846 private readonly _model : ITextModel ;
847847 private readonly _semanticStyling : SemanticStyling ;
848- private readonly _fetchSemanticTokens : RunOnceScheduler ;
849- private _currentResponse : SemanticTokensResponse | null ;
850- private _currentRequestCancellationTokenSource : CancellationTokenSource | null ;
851- private _providersChangeListeners : IDisposable [ ] ;
848+ private readonly _fetchDocumentSemanticTokens : RunOnceScheduler ;
849+ private _currentDocumentResponse : SemanticTokensResponse | null ;
850+ private _currentDocumentRequestCancellationTokenSource : CancellationTokenSource | null ;
851+ private _documentProvidersChangeListeners : IDisposable [ ] ;
852852
853853 constructor ( model : ITextModel , themeService : IThemeService , stylingProvider : SemanticStyling ) {
854854 super ( ) ;
855855
856856 this . _isDisposed = false ;
857857 this . _model = model ;
858858 this . _semanticStyling = stylingProvider ;
859- this . _fetchSemanticTokens = this . _register ( new RunOnceScheduler ( ( ) => this . _fetchSemanticTokensNow ( ) , 300 ) ) ;
860- this . _currentResponse = null ;
861- this . _currentRequestCancellationTokenSource = null ;
862- this . _providersChangeListeners = [ ] ;
859+ this . _fetchDocumentSemanticTokens = this . _register ( new RunOnceScheduler ( ( ) => this . _fetchDocumentSemanticTokensNow ( ) , 300 ) ) ;
860+ this . _currentDocumentResponse = null ;
861+ this . _currentDocumentRequestCancellationTokenSource = null ;
862+ this . _documentProvidersChangeListeners = [ ] ;
863863
864864 this . _register ( this . _model . onDidChangeContent ( e => {
865- if ( ! this . _fetchSemanticTokens . isScheduled ( ) ) {
866- this . _fetchSemanticTokens . schedule ( ) ;
865+ if ( ! this . _fetchDocumentSemanticTokens . isScheduled ( ) ) {
866+ this . _fetchDocumentSemanticTokens . schedule ( ) ;
867867 }
868868 } ) ) ;
869- const bindChangeListeners = ( ) => {
870- dispose ( this . _providersChangeListeners ) ;
871- this . _providersChangeListeners = [ ] ;
869+ const bindDocumentChangeListeners = ( ) => {
870+ dispose ( this . _documentProvidersChangeListeners ) ;
871+ this . _documentProvidersChangeListeners = [ ] ;
872872 for ( const provider of DocumentSemanticTokensProviderRegistry . all ( model ) ) {
873873 if ( typeof provider . onDidChange === 'function' ) {
874- this . _providersChangeListeners . push ( provider . onDidChange ( ( ) => this . _fetchSemanticTokens . schedule ( 0 ) ) ) ;
874+ this . _documentProvidersChangeListeners . push ( provider . onDidChange ( ( ) => this . _fetchDocumentSemanticTokens . schedule ( 0 ) ) ) ;
875875 }
876876 }
877877 } ;
878- bindChangeListeners ( ) ;
878+ bindDocumentChangeListeners ( ) ;
879879 this . _register ( DocumentSemanticTokensProviderRegistry . onDidChange ( e => {
880- bindChangeListeners ( ) ;
881- this . _fetchSemanticTokens . schedule ( ) ;
880+ bindDocumentChangeListeners ( ) ;
881+ this . _fetchDocumentSemanticTokens . schedule ( ) ;
882882 } ) ) ;
883883
884884 this . _register ( themeService . onDidColorThemeChange ( _ => {
885885 // clear out existing tokens
886- this . _setSemanticTokens ( null , null , null , [ ] ) ;
887- this . _fetchSemanticTokens . schedule ( ) ;
886+ this . _setDocumentSemanticTokens ( null , null , null , [ ] ) ;
887+ this . _fetchDocumentSemanticTokens . schedule ( ) ;
888888 } ) ) ;
889889
890- this . _fetchSemanticTokens . schedule ( 0 ) ;
890+ this . _fetchDocumentSemanticTokens . schedule ( 0 ) ;
891891 }
892892
893893 public dispose ( ) : void {
894- if ( this . _currentResponse ) {
895- this . _currentResponse . dispose ( ) ;
896- this . _currentResponse = null ;
894+ if ( this . _currentDocumentResponse ) {
895+ this . _currentDocumentResponse . dispose ( ) ;
896+ this . _currentDocumentResponse = null ;
897897 }
898- if ( this . _currentRequestCancellationTokenSource ) {
899- this . _currentRequestCancellationTokenSource . cancel ( ) ;
900- this . _currentRequestCancellationTokenSource = null ;
898+ if ( this . _currentDocumentRequestCancellationTokenSource ) {
899+ this . _currentDocumentRequestCancellationTokenSource . cancel ( ) ;
900+ this . _currentDocumentRequestCancellationTokenSource = null ;
901901 }
902- this . _setSemanticTokens ( null , null , null , [ ] ) ;
902+ this . _setDocumentSemanticTokens ( null , null , null , [ ] ) ;
903903 this . _isDisposed = true ;
904904
905905 super . dispose ( ) ;
906906 }
907907
908- private _fetchSemanticTokensNow ( ) : void {
909- if ( this . _currentRequestCancellationTokenSource ) {
908+ private _fetchDocumentSemanticTokensNow ( ) : void {
909+ if ( this . _currentDocumentRequestCancellationTokenSource ) {
910910 // there is already a request running, let it finish...
911911 return ;
912912 }
913913 const provider = this . _getSemanticColoringProvider ( ) ;
914914 if ( ! provider ) {
915915 return ;
916916 }
917- this . _currentRequestCancellationTokenSource = new CancellationTokenSource ( ) ;
917+ this . _currentDocumentRequestCancellationTokenSource = new CancellationTokenSource ( ) ;
918918
919919 const pendingChanges : IModelContentChangedEvent [ ] = [ ] ;
920920 const contentChangeListener = this . _model . onDidChangeContent ( ( e ) => {
@@ -923,27 +923,27 @@ class ModelSemanticColoring extends Disposable {
923923
924924 const styling = this . _semanticStyling . get ( provider ) ;
925925
926- const lastResultId = this . _currentResponse ? this . _currentResponse . resultId || null : null ;
927- const request = Promise . resolve ( provider . provideDocumentSemanticTokens ( this . _model , lastResultId , this . _currentRequestCancellationTokenSource . token ) ) ;
926+ const lastResultId = this . _currentDocumentResponse ? this . _currentDocumentResponse . resultId || null : null ;
927+ const request = Promise . resolve ( provider . provideDocumentSemanticTokens ( this . _model , lastResultId , this . _currentDocumentRequestCancellationTokenSource . token ) ) ;
928928
929929 request . then ( ( res ) => {
930- this . _currentRequestCancellationTokenSource = null ;
930+ this . _currentDocumentRequestCancellationTokenSource = null ;
931931 contentChangeListener . dispose ( ) ;
932- this . _setSemanticTokens ( provider , res || null , styling , pendingChanges ) ;
932+ this . _setDocumentSemanticTokens ( provider , res || null , styling , pendingChanges ) ;
933933 } , ( err ) => {
934934 if ( ! err || typeof err . message !== 'string' || err . message . indexOf ( 'busy' ) === - 1 ) {
935935 errors . onUnexpectedError ( err ) ;
936936 }
937937
938938 // Semantic tokens eats up all errors and considers errors to mean that the result is temporarily not available
939939 // The API does not have a special error kind to express this...
940- this . _currentRequestCancellationTokenSource = null ;
940+ this . _currentDocumentRequestCancellationTokenSource = null ;
941941 contentChangeListener . dispose ( ) ;
942942
943943 if ( pendingChanges . length > 0 ) {
944944 // More changes occurred while the request was running
945- if ( ! this . _fetchSemanticTokens . isScheduled ( ) ) {
946- this . _fetchSemanticTokens . schedule ( ) ;
945+ if ( ! this . _fetchDocumentSemanticTokens . isScheduled ( ) ) {
946+ this . _fetchDocumentSemanticTokens . schedule ( ) ;
947947 }
948948 }
949949 } ) ;
@@ -963,11 +963,11 @@ class ModelSemanticColoring extends Disposable {
963963 }
964964 }
965965
966- private _setSemanticTokens ( provider : DocumentSemanticTokensProvider | null , tokens : SemanticTokens | SemanticTokensEdits | null , styling : SemanticColoringProviderStyling | null , pendingChanges : IModelContentChangedEvent [ ] ) : void {
967- const currentResponse = this . _currentResponse ;
968- if ( this . _currentResponse ) {
969- this . _currentResponse . dispose ( ) ;
970- this . _currentResponse = null ;
966+ private _setDocumentSemanticTokens ( provider : DocumentSemanticTokensProvider | null , tokens : SemanticTokens | SemanticTokensEdits | null , styling : SemanticColoringProviderStyling | null , pendingChanges : IModelContentChangedEvent [ ] ) : void {
967+ const currentResponse = this . _currentDocumentResponse ;
968+ if ( this . _currentDocumentResponse ) {
969+ this . _currentDocumentResponse . dispose ( ) ;
970+ this . _currentDocumentResponse = null ;
971971 }
972972 if ( this . _isDisposed ) {
973973 // disposed!
@@ -1034,7 +1034,7 @@ class ModelSemanticColoring extends Disposable {
10341034
10351035 if ( ModelSemanticColoring . _isSemanticTokens ( tokens ) ) {
10361036
1037- this . _currentResponse = new SemanticTokensResponse ( provider , tokens . resultId , tokens . data ) ;
1037+ this . _currentDocumentResponse = new SemanticTokensResponse ( provider , tokens . resultId , tokens . data ) ;
10381038
10391039 const srcData = tokens . data ;
10401040 const tokenCount = ( tokens . data . length / 5 ) | 0 ;
@@ -1121,8 +1121,8 @@ class ModelSemanticColoring extends Disposable {
11211121 }
11221122 }
11231123
1124- if ( ! this . _fetchSemanticTokens . isScheduled ( ) ) {
1125- this . _fetchSemanticTokens . schedule ( ) ;
1124+ if ( ! this . _fetchDocumentSemanticTokens . isScheduled ( ) ) {
1125+ this . _fetchDocumentSemanticTokens . schedule ( ) ;
11261126 }
11271127 }
11281128
0 commit comments