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

Method handle_document_symbol

src/document_symbols.rs:33–98  ·  view source on GitHub ↗

DocumentSymbol::deprecated is deprecated in the LSP types crate

(
        &self,
        uri: &str,
        content: &str,
    )

Source from the content-addressed store, hash-verified

31 /// Returns `None` when the file has no symbols at all.
32 #[allow(deprecated)] // DocumentSymbol::deprecated is deprecated in the LSP types crate
33 pub fn handle_document_symbol(
34 &self,
35 uri: &str,
36 content: &str,
37 ) -> Option<DocumentSymbolResponse> {
38 let mut symbols: Vec<DocumentSymbol> = Vec::new();
39
40 // ── Classes, interfaces, traits, enums ──────────────────────
41 if let Some(classes) = self.uri_classes_index.read().get(uri).cloned() {
42 for class in &classes {
43 if let Some(sym) = class_to_symbol(class, content) {
44 symbols.push(sym);
45 }
46 }
47 }
48
49 // ── Standalone functions ────────────────────────────────────
50 {
51 let fmap = self.global_functions.read();
52 for (_name, (file_uri, func)) in fmap.iter() {
53 if file_uri == uri
54 && let Some(sym) = function_to_symbol(func, content)
55 {
56 symbols.push(sym);
57 }
58 }
59 }
60
61 // ── Global defines / constants ──────────────────────────────
62 {
63 let dmap = self.global_defines.read();
64 for (name, info) in dmap.iter() {
65 if info.file_uri == uri && info.name_offset > 0 {
66 let pos = offset_to_position(content, info.name_offset as usize);
67 let name_end =
68 offset_to_position(content, info.name_offset as usize + name.len());
69 let range = Range::new(pos, name_end);
70 symbols.push(DocumentSymbol {
71 name: name.clone(),
72 detail: info.value.clone(),
73 kind: SymbolKind::CONSTANT,
74 tags: None,
75 deprecated: None,
76 range,
77 selection_range: range,
78 children: None,
79 });
80 }
81 }
82 }
83
84 // Sort by position so the outline matches source order.
85 symbols.sort_by(|a, b| {
86 a.range
87 .start
88 .line
89 .cmp(&b.range.start.line)
90 .then(a.range.start.character.cmp(&b.range.start.character))

Callers 2

document_symbolMethod · 0.80
get_symbolsFunction · 0.80

Calls 8

class_to_symbolFunction · 0.85
function_to_symbolFunction · 0.85
offset_to_positionFunction · 0.85
pushMethod · 0.80
iterMethod · 0.80
cloneMethod · 0.80
getMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected