MCPcopy Create free account
hub / github.com/microsoft/typescript-go / getAsyncAndAwaitOccurrences

Function getAsyncAndAwaitOccurrences

internal/ls/documenthighlights.go:619–646  ·  view source on GitHub ↗
(node *ast.Node, sourceFile *ast.SourceFile)

Source from the content-addressed store, hash-verified

617}
618
619func getAsyncAndAwaitOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node {
620 fun := ast.GetContainingFunction(node)
621 if fun == nil {
622 return nil
623 }
624
625 var keywords []*ast.Node
626
627 for _, modifier := range fun.ModifierNodes() {
628 if modifier.Kind == ast.KindAsyncKeyword {
629 keywords = append(keywords, modifier)
630 }
631 }
632
633 fun.ForEachChild(func(child *ast.Node) bool {
634 traverseWithoutCrossingFunction(child, sourceFile, func(child *ast.Node) {
635 if ast.IsAwaitExpression(child) {
636 token := lsutil.GetFirstToken(child, sourceFile)
637 if token.Kind == ast.KindAwaitKeyword {
638 keywords = append(keywords, token)
639 }
640 }
641 })
642 return false // continue traversal
643 })
644
645 return keywords
646}
647
648func getYieldOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node {
649 parentFunc := ast.FindAncestor(node.Parent, ast.IsFunctionLike)

Callers 1

Calls 7

GetContainingFunctionFunction · 0.92
IsAwaitExpressionFunction · 0.92
GetFirstTokenFunction · 0.92
ModifierNodesMethod · 0.80
ForEachChildMethod · 0.65
appendFunction · 0.50

Tested by

no test coverage detected