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

Function FindPrecedingToken

internal/astnav/tokens.go:328–330  ·  view source on GitHub ↗

Finds the leftmost token satisfying `position < token.End()`. If the leftmost token satisfying `position < token.End()` is invalid, or if position is in the trivia of that leftmost token, we will find the rightmost valid token with `token.End() <= position`.

(sourceFile *ast.SourceFile, position int)

Source from the content-addressed store, hash-verified

326// is in the trivia of that leftmost token,
327// we will find the rightmost valid token with `token.End() <= position`.
328func FindPrecedingToken(sourceFile *ast.SourceFile, position int) *ast.Node {
329 return FindPrecedingTokenEx(sourceFile, position, nil, false)
330}
331
332func FindPrecedingTokenEx(sourceFile *ast.SourceFile, position int, startNode *ast.Node, excludeJSDoc bool) *ast.Node {
333 var find func(node *ast.Node) *ast.Node

Callers 15

ProvideOnAutoInsertMethod · 0.92
createCompletionItemMethod · 0.92
getRelevantTokensFunction · 0.92
GetSignatureHelpItemsMethod · 0.92
isInCommentFunction · 0.92
InsertNodeInListAfterMethod · 0.92

Calls 1

FindPrecedingTokenExFunction · 0.85

Tested by 2

TestFindPrecedingTokenFunction · 0.74