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

Method handleGetReferencesToSymbolInFile

internal/api/session.go:3123–3149  ·  view source on GitHub ↗

handleGetReferencesToSymbolInFile returns node handles for all identifiers in a file that reference the given symbol.

(ctx context.Context, params *GetReferencesToSymbolInFileParams)

Source from the content-addressed store, hash-verified

3121
3122// handleGetReferencesToSymbolInFile returns node handles for all identifiers in a file that reference the given symbol.
3123func (s *Session) handleGetReferencesToSymbolInFile(ctx context.Context, params *GetReferencesToSymbolInFileParams) ([]NodeHandle, error) {
3124 setup, err := s.setupChecker(ctx, params.Snapshot, params.Project)
3125 if err != nil {
3126 return nil, err
3127 }
3128 defer setup.done()
3129
3130 symbol, err := setup.resolveSymbolHandle(params.Symbol)
3131 if err != nil {
3132 return nil, err
3133 }
3134 if symbol == nil {
3135 return nil, nil
3136 }
3137
3138 sourceFile := setup.program.GetSourceFile(params.File.ToFileName())
3139 if sourceFile == nil {
3140 return nil, fmt.Errorf("%w: source file not found: %v", ErrClientError, params.File)
3141 }
3142
3143 nodes := setup.checker.GetReferencesToSymbolInFile(sourceFile, symbol)
3144 result := make([]NodeHandle, len(nodes))
3145 for i, node := range nodes {
3146 result[i] = setup.sd.nodeHandleFrom(node)
3147 }
3148 return result, nil
3149}
3150
3151func (s *Session) handleGetSignatureUsages(ctx context.Context, params *GetSignatureUsagesParams) ([]SignatureUsageResponse, error) {
3152 sd, err := s.getSnapshotData(params.Snapshot)

Callers 1

HandleRequestMethod · 0.95

Calls 10

setupCheckerMethod · 0.95
lenFunction · 0.85
ToFileNameMethod · 0.80
nodeHandleFromMethod · 0.80
doneMethod · 0.65
GetSourceFileMethod · 0.65
ErrorfMethod · 0.65
makeFunction · 0.50
resolveSymbolHandleMethod · 0.45

Tested by

no test coverage detected