handleGetSymbolAtPosition returns the symbol at a position in a file.
(ctx context.Context, params *GetSymbolAtPositionParams)
| 1126 | |
| 1127 | // handleGetSymbolAtPosition returns the symbol at a position in a file. |
| 1128 | func (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. |
| 1155 | func (s *Session) handleGetSymbolsAtPositions(ctx context.Context, params *GetSymbolsAtPositionsParams) ([]*SymbolResponse, error) { |
no test coverage detected