@@ -74,6 +74,10 @@ namespace ts.DocumentHighlights {
74
74
case SyntaxKind . GetKeyword :
75
75
case SyntaxKind . SetKeyword :
76
76
return getFromAllDeclarations ( isAccessor , [ SyntaxKind . GetKeyword , SyntaxKind . SetKeyword ] ) ;
77
+ case SyntaxKind . AwaitKeyword :
78
+ return useParent ( node . parent , isAwaitExpression , getAsyncAndAwaitOccurrences ) ;
79
+ case SyntaxKind . AsyncKeyword :
80
+ return highlightSpans ( getAsyncAndAwaitOccurrences ( node ) ) ;
77
81
default :
78
82
return isModifierKind ( node . kind ) && ( isDeclaration ( node . parent ) || isVariableStatement ( node . parent ) )
79
83
? highlightSpans ( getModifierOccurrences ( node . kind , node . parent ) )
@@ -368,6 +372,35 @@ namespace ts.DocumentHighlights {
368
372
return keywords ;
369
373
}
370
374
375
+ function getAsyncAndAwaitOccurrences ( node : Node ) : Node [ ] | undefined {
376
+ const func = < FunctionLikeDeclaration > getContainingFunction ( node ) ;
377
+ if ( ! func ) {
378
+ return undefined ;
379
+ }
380
+
381
+ const keywords : Node [ ] = [ ] ;
382
+
383
+ if ( func . modifiers ) {
384
+ func . modifiers . forEach ( modifier => {
385
+ pushKeywordIf ( keywords , modifier , SyntaxKind . AsyncKeyword ) ;
386
+ } ) ;
387
+ }
388
+
389
+ forEachChild ( func , aggregate ) ;
390
+
391
+ return keywords ;
392
+
393
+ function aggregate ( node : Node ) : void {
394
+ if ( isAwaitExpression ( node ) ) {
395
+ pushKeywordIf ( keywords , node . getFirstToken ( ) , SyntaxKind . AwaitKeyword ) ;
396
+ }
397
+ // Do not cross function boundaries.
398
+ if ( ! isFunctionLike ( node ) && ! isClassLike ( node ) && ! isInterfaceDeclaration ( node ) && ! isModuleDeclaration ( node ) && ! isTypeAliasDeclaration ( node ) && ! isTypeNode ( node ) ) {
399
+ forEachChild ( node , aggregate ) ;
400
+ }
401
+ }
402
+ }
403
+
371
404
function getIfElseOccurrences ( ifStatement : IfStatement , sourceFile : SourceFile ) : HighlightSpan [ ] {
372
405
const keywords = getIfElseKeywords ( ifStatement , sourceFile ) ;
373
406
const result : HighlightSpan [ ] = [ ] ;
0 commit comments