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

Method handle_inlay_hints

src/inlay_hints.rs:46–106  ·  view source on GitHub ↗

Handle a `textDocument/inlayHint` request. Returns inlay hints for call-site parameter names and by-reference indicators within the given range.

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

Source from the content-addressed store, hash-verified

44 /// Returns inlay hints for call-site parameter names and by-reference
45 /// indicators within the given range.
46 pub fn handle_inlay_hints(
47 &self,
48 uri: &str,
49 content: &str,
50 range: Range,
51 ) -> Option<Vec<InlayHint>> {
52 let symbol_map = self.symbol_maps.read().get(uri).cloned()?;
53 let ctx = self.file_context(uri);
54
55 // If this is a Blade file, the `range` is in Blade coordinates.
56 // We must translate it to virtual PHP coordinates before comparing
57 // against offsets in the symbol map.
58 let virtual_range = if self.is_blade_file(uri) {
59 Range {
60 start: self.translate_blade_to_php(uri, range.start),
61 end: self.translate_blade_to_php(uri, range.end),
62 }
63 } else {
64 range
65 };
66
67 let range_start = position_to_offset(content, virtual_range.start);
68 let range_end = position_to_offset(content, virtual_range.end);
69
70 let mut hints = Vec::new();
71
72 for call_site in &symbol_map.call_sites {
73 // Skip call sites entirely outside the requested range.
74 if call_site.args_end < range_start || call_site.args_start > range_end {
75 continue;
76 }
77
78 // Skip calls with no arguments.
79 if call_site.arg_count == 0 {
80 continue;
81 }
82
83 self.emit_parameter_hints(call_site, content, range, &ctx, &mut hints);
84 }
85
86 // ── Closure / arrow function hints ──────────────────────────
87 if !symbol_map.untyped_closure_sites.is_empty() {
88 self.emit_closure_hints(
89 content,
90 &symbol_map.untyped_closure_sites,
91 &symbol_map.call_sites,
92 (range_start, range_end),
93 &ctx,
94 &mut hints,
95 );
96 }
97
98 // Translate hints back to Blade if needed.
99 if self.is_blade_file(uri) {
100 for hint in &mut hints {
101 hint.position = self.translate_php_to_blade(uri, hint.position);
102 }
103 }

Callers 3

inlay_hint_requestMethod · 0.80
inlay_hints_forFunction · 0.80

Calls 9

file_contextMethod · 0.80
is_blade_fileMethod · 0.80
emit_parameter_hintsMethod · 0.80
emit_closure_hintsMethod · 0.80
position_to_offsetFunction · 0.70
getMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected