@@ -18,7 +18,7 @@ import { format } from './modes/formatting';
1818import { pushAll } from './utils/arrays' ;
1919import { getDocumentContext } from './utils/documentContext' ;
2020import { URI } from 'vscode-uri' ;
21- import { formatError , runSafe , runSafeAsync } from './utils/runner' ;
21+ import { formatError , runSafe } from './utils/runner' ;
2222
2323import { getFoldingRanges } from './modes/htmlFolding' ;
2424import { fetchHTMLDataProviders } from './customData' ;
@@ -261,11 +261,11 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
261261 const settings = await getDocumentSettings ( textDocument , ( ) => modes . some ( m => ! ! m . doValidation ) ) ;
262262 const latestTextDocument = documents . get ( textDocument . uri ) ;
263263 if ( latestTextDocument && latestTextDocument . version === version ) { // check no new version has come in after in after the async op
264- modes . forEach ( mode => {
264+ for ( const mode of modes ) {
265265 if ( mode . doValidation && isValidationEnabled ( mode . getId ( ) , settings ) ) {
266- pushAll ( diagnostics , mode . doValidation ( latestTextDocument , settings ) ) ;
266+ pushAll ( diagnostics , await mode . doValidation ( latestTextDocument , settings ) ) ;
267267 }
268- } ) ;
268+ }
269269 connection . sendDiagnostics ( { uri : latestTextDocument . uri , diagnostics } ) ;
270270 }
271271 }
@@ -275,7 +275,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
275275 }
276276
277277 connection . onCompletion ( async ( textDocumentPosition , token ) => {
278- return runSafeAsync ( async ( ) => {
278+ return runSafe ( async ( ) => {
279279 const document = documents . get ( textDocumentPosition . textDocument . uri ) ;
280280 if ( ! document ) {
281281 return null ;
@@ -303,7 +303,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
303303 } ) ;
304304
305305 connection . onCompletionResolve ( ( item , token ) => {
306- return runSafe ( ( ) => {
306+ return runSafe ( async ( ) => {
307307 const data = item . data ;
308308 if ( data && data . languageId && data . uri ) {
309309 const mode = languageModes . getMode ( data . languageId ) ;
@@ -317,7 +317,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
317317 } ) ;
318318
319319 connection . onHover ( ( textDocumentPosition , token ) => {
320- return runSafe ( ( ) => {
320+ return runSafe ( async ( ) => {
321321 const document = documents . get ( textDocumentPosition . textDocument . uri ) ;
322322 if ( document ) {
323323 const mode = languageModes . getModeAtPosition ( document , textDocumentPosition . position ) ;
@@ -330,7 +330,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
330330 } ) ;
331331
332332 connection . onDocumentHighlight ( ( documentHighlightParams , token ) => {
333- return runSafe ( ( ) => {
333+ return runSafe ( async ( ) => {
334334 const document = documents . get ( documentHighlightParams . textDocument . uri ) ;
335335 if ( document ) {
336336 const mode = languageModes . getModeAtPosition ( document , documentHighlightParams . position ) ;
@@ -343,7 +343,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
343343 } ) ;
344344
345345 connection . onDefinition ( ( definitionParams , token ) => {
346- return runSafe ( ( ) => {
346+ return runSafe ( async ( ) => {
347347 const document = documents . get ( definitionParams . textDocument . uri ) ;
348348 if ( document ) {
349349 const mode = languageModes . getModeAtPosition ( document , definitionParams . position ) ;
@@ -356,7 +356,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
356356 } ) ;
357357
358358 connection . onReferences ( ( referenceParams , token ) => {
359- return runSafe ( ( ) => {
359+ return runSafe ( async ( ) => {
360360 const document = documents . get ( referenceParams . textDocument . uri ) ;
361361 if ( document ) {
362362 const mode = languageModes . getModeAtPosition ( document , referenceParams . position ) ;
@@ -369,7 +369,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
369369 } ) ;
370370
371371 connection . onSignatureHelp ( ( signatureHelpParms , token ) => {
372- return runSafe ( ( ) => {
372+ return runSafe ( async ( ) => {
373373 const document = documents . get ( signatureHelpParms . textDocument . uri ) ;
374374 if ( document ) {
375375 const mode = languageModes . getModeAtPosition ( document , signatureHelpParms . position ) ;
@@ -382,7 +382,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
382382 } ) ;
383383
384384 connection . onDocumentRangeFormatting ( async ( formatParams , token ) => {
385- return runSafeAsync ( async ( ) => {
385+ return runSafe ( async ( ) => {
386386 const document = documents . get ( formatParams . textDocument . uri ) ;
387387 if ( document ) {
388388 let settings = await getDocumentSettings ( document , ( ) => true ) ;
@@ -399,53 +399,53 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
399399 } ) ;
400400
401401 connection . onDocumentLinks ( ( documentLinkParam , token ) => {
402- return runSafe ( ( ) => {
402+ return runSafe ( async ( ) => {
403403 const document = documents . get ( documentLinkParam . textDocument . uri ) ;
404404 const links : DocumentLink [ ] = [ ] ;
405405 if ( document ) {
406406 const documentContext = getDocumentContext ( document . uri , workspaceFolders ) ;
407- languageModes . getAllModesInDocument ( document ) . forEach ( m => {
407+ for ( const m of languageModes . getAllModesInDocument ( document ) ) {
408408 if ( m . findDocumentLinks ) {
409- pushAll ( links , m . findDocumentLinks ( document , documentContext ) ) ;
409+ pushAll ( links , await m . findDocumentLinks ( document , documentContext ) ) ;
410410 }
411- } ) ;
411+ }
412412 }
413413 return links ;
414414 } , [ ] , `Error while document links for ${ documentLinkParam . textDocument . uri } ` , token ) ;
415415 } ) ;
416416
417417 connection . onDocumentSymbol ( ( documentSymbolParms , token ) => {
418- return runSafe ( ( ) => {
418+ return runSafe ( async ( ) => {
419419 const document = documents . get ( documentSymbolParms . textDocument . uri ) ;
420420 const symbols : SymbolInformation [ ] = [ ] ;
421421 if ( document ) {
422- languageModes . getAllModesInDocument ( document ) . forEach ( m => {
422+ for ( const m of languageModes . getAllModesInDocument ( document ) ) {
423423 if ( m . findDocumentSymbols ) {
424- pushAll ( symbols , m . findDocumentSymbols ( document ) ) ;
424+ pushAll ( symbols , await m . findDocumentSymbols ( document ) ) ;
425425 }
426- } ) ;
426+ }
427427 }
428428 return symbols ;
429429 } , [ ] , `Error while computing document symbols for ${ documentSymbolParms . textDocument . uri } ` , token ) ;
430430 } ) ;
431431
432432 connection . onRequest ( DocumentColorRequest . type , ( params , token ) => {
433- return runSafe ( ( ) => {
433+ return runSafe ( async ( ) => {
434434 const infos : ColorInformation [ ] = [ ] ;
435435 const document = documents . get ( params . textDocument . uri ) ;
436436 if ( document ) {
437- languageModes . getAllModesInDocument ( document ) . forEach ( m => {
437+ for ( const m of languageModes . getAllModesInDocument ( document ) ) {
438438 if ( m . findDocumentColors ) {
439- pushAll ( infos , m . findDocumentColors ( document ) ) ;
439+ pushAll ( infos , await m . findDocumentColors ( document ) ) ;
440440 }
441- } ) ;
441+ }
442442 }
443443 return infos ;
444444 } , [ ] , `Error while computing document colors for ${ params . textDocument . uri } ` , token ) ;
445445 } ) ;
446446
447447 connection . onRequest ( ColorPresentationRequest . type , ( params , token ) => {
448- return runSafe ( ( ) => {
448+ return runSafe ( async ( ) => {
449449 const document = documents . get ( params . textDocument . uri ) ;
450450 if ( document ) {
451451 const mode = languageModes . getModeAtPosition ( document , params . range . start ) ;
@@ -458,7 +458,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
458458 } ) ;
459459
460460 connection . onRequest ( TagCloseRequest . type , ( params , token ) => {
461- return runSafe ( ( ) => {
461+ return runSafe ( async ( ) => {
462462 const document = documents . get ( params . textDocument . uri ) ;
463463 if ( document ) {
464464 const pos = params . position ;
@@ -474,7 +474,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
474474 } ) ;
475475
476476 connection . onFoldingRanges ( ( params , token ) => {
477- return runSafe ( ( ) => {
477+ return runSafe ( async ( ) => {
478478 const document = documents . get ( params . textDocument . uri ) ;
479479 if ( document ) {
480480 return getFoldingRanges ( languageModes , document , foldingRangeLimit , token ) ;
@@ -484,7 +484,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
484484 } ) ;
485485
486486 connection . onSelectionRanges ( ( params , token ) => {
487- return runSafe ( ( ) => {
487+ return runSafe ( async ( ) => {
488488 const document = documents . get ( params . textDocument . uri ) ;
489489 if ( document ) {
490490 return getSelectionRanges ( languageModes , document , params . positions ) ;
@@ -494,7 +494,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
494494 } ) ;
495495
496496 connection . onRenameRequest ( ( params , token ) => {
497- return runSafe ( ( ) => {
497+ return runSafe ( async ( ) => {
498498 const document = documents . get ( params . textDocument . uri ) ;
499499 const position : Position = params . position ;
500500
@@ -509,7 +509,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
509509 } ) ;
510510
511511 connection . onRequest ( OnTypeRenameRequest . type , ( params , token ) => {
512- return runSafe ( ( ) => {
512+ return runSafe ( async ( ) => {
513513 const document = documents . get ( params . textDocument . uri ) ;
514514 if ( document ) {
515515 const pos = params . position ;
@@ -533,7 +533,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
533533 }
534534
535535 connection . onRequest ( SemanticTokenRequest . type , ( params , token ) => {
536- return runSafe ( ( ) => {
536+ return runSafe ( async ( ) => {
537537 const document = documents . get ( params . textDocument . uri ) ;
538538 if ( document ) {
539539 return getSemanticTokenProvider ( ) . getSemanticTokens ( document , params . ranges ) ;
@@ -543,7 +543,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
543543 } ) ;
544544
545545 connection . onRequest ( SemanticTokenLegendRequest . type , ( _params , token ) => {
546- return runSafe ( ( ) => {
546+ return runSafe ( async ( ) => {
547547 return getSemanticTokenProvider ( ) . legend ;
548548 } , null , `Error while computing semantic tokens legend` , token ) ;
549549 } ) ;
0 commit comments