@@ -114,17 +114,17 @@ export class SemanticHighlightingFeature implements vscodelc.StaticFeature {
114
114
this . loadCurrentTheme ( ) ;
115
115
// Event handling for handling with TextDocuments/Editors lifetimes.
116
116
this . subscriptions . push ( vscode . window . onDidChangeVisibleTextEditors (
117
- ( editors : vscode . TextEditor [ ] ) =>
118
- editors . forEach ( ( e ) => this . highlighter . applyHighlights (
119
- e . document . uri . toString ( ) ) ) ) ) ;
117
+ ( editors : vscode . TextEditor [ ] ) => editors . forEach (
118
+ ( e ) => this . highlighter . applyHighlights ( e . document . uri ) ) ) ) ;
120
119
this . subscriptions . push ( vscode . workspace . onDidCloseTextDocument (
121
- ( doc ) => this . highlighter . removeFileHighlightings ( doc . uri . toString ( ) ) ) ) ;
120
+ ( doc ) => this . highlighter . removeFileHighlightings ( doc . uri ) ) ) ;
122
121
}
123
122
124
123
handleNotification ( params : SemanticHighlightingParams ) {
125
124
const lines : SemanticHighlightingLine [ ] = params . lines . map (
126
125
( line ) => ( { line : line . line , tokens : decodeTokens ( line . tokens ) } ) ) ;
127
- this . highlighter . highlight ( params . textDocument . uri , lines ) ;
126
+ this . highlighter . highlight ( vscode . Uri . parse ( params . textDocument . uri ) ,
127
+ lines ) ;
128
128
}
129
129
// Disposes of all disposable resources used by this object.
130
130
public dispose ( ) {
@@ -199,19 +199,21 @@ export class Highlighter {
199
199
// Adds incremental highlightings to the current highlightings for the file
200
200
// with fileUri. Also applies the highlightings to any associated
201
201
// TextEditor(s).
202
- public highlight ( fileUri : string ,
202
+ public highlight ( fileUri : vscode . Uri ,
203
203
highlightingLines : SemanticHighlightingLine [ ] ) {
204
- if ( ! this . files . has ( fileUri ) ) {
205
- this . files . set ( fileUri , new Map ( ) ) ;
204
+ const fileUriStr = fileUri . toString ( ) ;
205
+ if ( ! this . files . has ( fileUriStr ) ) {
206
+ this . files . set ( fileUriStr , new Map ( ) ) ;
206
207
}
207
- const fileHighlightings = this . files . get ( fileUri ) ;
208
+ const fileHighlightings = this . files . get ( fileUriStr ) ;
208
209
highlightingLines . forEach ( ( line ) => fileHighlightings . set ( line . line , line ) ) ;
209
210
this . applyHighlights ( fileUri ) ;
210
211
}
211
212
212
213
// Applies all the highlightings currently stored for a file with fileUri.
213
- public applyHighlights ( fileUri : string ) {
214
- if ( ! this . files . has ( fileUri ) )
214
+ public applyHighlights ( fileUri : vscode . Uri ) {
215
+ const fileUriStr = fileUri . toString ( ) ;
216
+ if ( ! this . files . has ( fileUriStr ) )
215
217
// There are no highlightings for this file, must return early or will get
216
218
// out of bounds when applying the decorations below.
217
219
return ;
@@ -224,35 +226,35 @@ export class Highlighter {
224
226
// TextEditorDecorationType is used per scope.
225
227
const ranges = this . getDecorationRanges ( fileUri ) ;
226
228
vscode . window . visibleTextEditors . forEach ( ( e ) => {
227
- if ( e . document . uri . toString ( ) !== fileUri )
229
+ if ( e . document . uri . toString ( ) !== fileUriStr )
228
230
return ;
229
231
this . decorationTypes . forEach ( ( d , i ) => e . setDecorations ( d , ranges [ i ] ) ) ;
230
232
} ) ;
231
233
}
232
234
233
235
// Called when a text document is closed. Removes any highlighting entries for
234
236
// the text document that was closed.
235
- public removeFileHighlightings ( fileUri : string ) {
237
+ public removeFileHighlightings ( fileUri : vscode . Uri ) {
236
238
// If there exists no entry the call to delete just returns false.
237
- this . files . delete ( fileUri ) ;
239
+ this . files . delete ( fileUri . toString ( ) ) ;
238
240
}
239
241
240
242
// Gets the uris as strings for the currently visible text editors.
241
- protected getVisibleTextEditorUris ( ) : string [ ] {
242
- return vscode . window . visibleTextEditors . map ( ( e ) =>
243
- e . document . uri . toString ( ) ) ;
243
+ protected getVisibleTextEditorUris ( ) : vscode . Uri [ ] {
244
+ return vscode . window . visibleTextEditors . map ( ( e ) => e . document . uri ) ;
244
245
}
245
246
246
247
// Returns the ranges that should be used when decorating. Index i in the
247
248
// range array has the decoration type at index i of this.decorationTypes.
248
- protected getDecorationRanges ( fileUri : string ) : vscode . Range [ ] [ ] {
249
- if ( ! this . files . has ( fileUri ) )
249
+ protected getDecorationRanges ( fileUri : vscode . Uri ) : vscode . Range [ ] [ ] {
250
+ const fileUriStr = fileUri . toString ( ) ;
251
+ if ( ! this . files . has ( fileUriStr ) )
250
252
// this.files should always have an entry for fileUri if we are here. But
251
253
// if there isn't one we don't want to crash the extension. This is also
252
254
// useful for tests.
253
255
return [ ] ;
254
256
const lines : SemanticHighlightingLine [ ] =
255
- Array . from ( this . files . get ( fileUri ) . values ( ) ) ;
257
+ Array . from ( this . files . get ( fileUriStr ) . values ( ) ) ;
256
258
const decorations : vscode . Range [ ] [ ] = this . decorationTypes . map ( ( ) => [ ] ) ;
257
259
lines . forEach ( ( line ) => {
258
260
line . tokens . forEach ( ( token ) => {
0 commit comments