MCPcopy Index your code
hub / github.com/microsoft/typescript-go / handleGetSymbolAtPosition

Method handleGetSymbolAtPosition

internal/api/session.go:1128–1152  ·  view source on GitHub ↗

handleGetSymbolAtPosition returns the symbol at a position in a file.

(ctx context.Context, params *GetSymbolAtPositionParams)

Source from the content-addressed store, hash-verified

1126
1127// handleGetSymbolAtPosition returns the symbol at a position in a file.
1128func (s *Session) handleGetSymbolAtPosition(ctx context.Context, params *GetSymbolAtPositionParams) (*SymbolResponse, error) {
1129 setup, err := s.setupChecker(ctx, params.Snapshot, params.Project)
1130 if err != nil {
1131 return nil, err
1132 }
1133 defer setup.done()
1134
1135 sourceFile := setup.program.GetSourceFile(params.File.ToFileName())
1136 if sourceFile == nil {
1137 return nil, fmt.Errorf("%w: source file not found: %v", ErrClientError, params.File)
1138 }
1139
1140 positionMap := sourceFile.GetPositionMap()
1141 node := astnav.GetTouchingPropertyName(sourceFile, positionMap.UTF16ToUTF8(int(params.Position)))
1142 if node == nil {
1143 return nil, nil
1144 }
1145
1146 symbol := setup.checker.GetSymbolAtLocation(node)
1147 if symbol == nil {
1148 return nil, nil
1149 }
1150
1151 return setup.newSymbolResponse(symbol), nil
1152}
1153
1154// handleGetSymbolsAtPositions returns symbols at multiple positions in a file.
1155func (s *Session) handleGetSymbolsAtPositions(ctx context.Context, params *GetSymbolsAtPositionsParams) ([]*SymbolResponse, error) {

Callers 1

HandleRequestMethod · 0.95

Calls 11

setupCheckerMethod · 0.95
GetTouchingPropertyNameFunction · 0.92
ToFileNameMethod · 0.80
GetPositionMapMethod · 0.80
UTF16ToUTF8Method · 0.80
doneMethod · 0.65
GetSourceFileMethod · 0.65
ErrorfMethod · 0.65
GetSymbolAtLocationMethod · 0.65
intInterface · 0.50
newSymbolResponseMethod · 0.45

Tested by

no test coverage detected