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

Method blade_echo_delimiter_hover

src/blade/mod.rs:125–175  ·  view source on GitHub ↗

If the cursor is on a `{{`, `}}`, `{!!`, or `!!}` Blade echo delimiter, return a hover describing the implicit `e()` call (for escaped echo) or raw output (for unescaped echo).

(
        &self,
        uri: &str,
        position: Position,
    )

Source from the content-addressed store, hash-verified

123 /// return a hover describing the implicit `e()` call (for escaped echo)
124 /// or raw output (for unescaped echo).
125 pub(crate) fn blade_echo_delimiter_hover(
126 &self,
127 uri: &str,
128 position: Position,
129 ) -> Option<Hover> {
130 let content = self.get_file_content(uri)?;
131 let line = content.lines().nth(position.line as usize)?;
132 let col = position.character as usize;
133
134 // Check if cursor is on `{{` (escaped echo open)
135 if col < line.len()
136 && line.get(col..col + 2) == Some("{{")
137 && line.get(col..col + 3) != Some("{!!")
138 {
139 return Some(self.blade_e_hover(position, 2));
140 }
141 // Also match if cursor is on the second `{` of `{{`
142 if col > 0
143 && line.get(col - 1..col + 1) == Some("{{")
144 && (col < 2 || line.get(col - 1..col + 2) != Some("{!!"))
145 {
146 return Some(self.blade_e_hover(
147 Position {
148 line: position.line,
149 character: (col - 1) as u32,
150 },
151 2,
152 ));
153 }
154 // `}}` closing delimiter
155 if col < line.len()
156 && line.get(col..col + 2) == Some("}}")
157 && (col == 0 || line.as_bytes().get(col - 1) != Some(&b'!'))
158 {
159 return Some(self.blade_e_hover(position, 2));
160 }
161 if col > 0
162 && line.get(col - 1..col + 1) == Some("}}")
163 && (col < 2 || line.as_bytes().get(col - 2) != Some(&b'!'))
164 {
165 return Some(self.blade_e_hover(
166 Position {
167 line: position.line,
168 character: (col - 1) as u32,
169 },
170 2,
171 ));
172 }
173
174 None
175 }
176
177 /// Build hover content for `{{ }}` (escaped echo via `e()`).
178 fn blade_e_hover(&self, start: Position, len: u32) -> Hover {

Callers 1

hoverMethod · 0.80

Calls 3

get_file_contentMethod · 0.80
blade_e_hoverMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected