MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / method_to_symbol

Function method_to_symbol

src/document_symbols.rs:205–242  ·  view source on GitHub ↗
(method: &MethodInfo, content: &str)

Source from the content-addressed store, hash-verified

203/// Convert a `MethodInfo` to a `DocumentSymbol`.
204#[allow(deprecated)]
205fn method_to_symbol(method: &MethodInfo, content: &str) -> Option<DocumentSymbol> {
206 if method.name_offset == 0 {
207 return None;
208 }
209
210 let pos = offset_to_position(content, method.name_offset as usize);
211 let name_end = offset_to_position(content, method.name_offset as usize + method.name.len());
212 let selection_range = Range::new(pos, name_end);
213
214 // For the full range, use the name offset as the start.
215 // We don't have the method's end offset readily available, so we
216 // use the selection range as a reasonable approximation.
217 let range = selection_range;
218
219 let detail = build_method_detail(method);
220 let tags = if method.deprecation_message.is_some() {
221 Some(vec![SymbolTag::DEPRECATED])
222 } else {
223 None
224 };
225
226 let kind = if method.name == "__construct" {
227 SymbolKind::CONSTRUCTOR
228 } else {
229 SymbolKind::METHOD
230 };
231
232 Some(DocumentSymbol {
233 name: method.name.to_string(),
234 detail,
235 kind,
236 tags,
237 deprecated: None,
238 range,
239 selection_range,
240 children: None,
241 })
242}
243
244/// Convert a `PropertyInfo` to a `DocumentSymbol`.
245#[allow(deprecated)]

Callers 1

class_to_symbolFunction · 0.85

Calls 2

offset_to_positionFunction · 0.85
build_method_detailFunction · 0.85

Tested by

no test coverage detected