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

Method GetSymbolAtPosition

internal/ls/api.go:18–30  ·  view source on GitHub ↗
(ctx context.Context, fileName string, position int)

Source from the content-addressed store, hash-verified

16)
17
18func (l *LanguageService) GetSymbolAtPosition(ctx context.Context, fileName string, position int) (*ast.Symbol, error) {
19 program, file := l.tryGetProgramAndFile(fileName)
20 if file == nil {
21 return nil, fmt.Errorf("%w: %s", ErrNoSourceFile, fileName)
22 }
23 node := astnav.GetTokenAtPosition(file, position)
24 if node == nil {
25 return nil, fmt.Errorf("%w: %s:%d", ErrNoTokenAtPosition, fileName, position)
26 }
27 checker, done := program.GetTypeCheckerForFile(ctx, file)
28 defer done()
29 return checker.GetSymbolAtLocation(node), nil
30}
31
32func (l *LanguageService) GetSymbolAtLocation(ctx context.Context, node *ast.Node) *ast.Symbol {
33 program := l.GetProgram()

Callers

nothing calls this directly

Calls 5

tryGetProgramAndFileMethod · 0.95
GetTokenAtPositionFunction · 0.92
GetTypeCheckerForFileMethod · 0.80
ErrorfMethod · 0.65
GetSymbolAtLocationMethod · 0.65

Tested by

no test coverage detected