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

Method highlight_member_name

src/highlight/mod.rs:240–292  ·  view source on GitHub ↗

Highlight all member accesses and declarations with the same name. This is a name-only match (no subject type resolution) which is acceptable for v1. It may produce false positives across unrelated classes in the same file, but that is a rare scenario.

(
        &self,
        symbol_map: &SymbolMap,
        content: &str,
        target_name: &str,
    )

Source from the content-addressed store, hash-verified

238 /// acceptable for v1. It may produce false positives across unrelated
239 /// classes in the same file, but that is a rare scenario.
240 fn highlight_member_name(
241 &self,
242 symbol_map: &SymbolMap,
243 content: &str,
244 target_name: &str,
245 ) -> Vec<DocumentHighlight> {
246 let mut highlights = Vec::new();
247
248 for span in &symbol_map.spans {
249 match &span.kind {
250 SymbolKind::MemberAccess { member_name, .. } if member_name == target_name => {
251 highlights.push(DocumentHighlight {
252 range: byte_range_to_lsp_range(
253 content,
254 span.start as usize,
255 span.end as usize,
256 ),
257 kind: Some(DocumentHighlightKind::READ),
258 });
259 }
260 SymbolKind::MemberDeclaration { name, .. } if name == target_name => {
261 highlights.push(DocumentHighlight {
262 range: byte_range_to_lsp_range(
263 content,
264 span.start as usize,
265 span.end as usize,
266 ),
267 kind: Some(DocumentHighlightKind::WRITE),
268 });
269 }
270 // Also match property declarations that appear as Variable spans.
271 SymbolKind::Variable { name }
272 if name == target_name
273 && symbol_map
274 .var_def_kind_at(name, span.start)
275 .is_some_and(|k| *k == VarDefKind::Property) =>
276 {
277 highlights.push(DocumentHighlight {
278 range: byte_range_to_lsp_range(
279 content,
280 span.start as usize,
281 span.end as usize,
282 ),
283 kind: Some(DocumentHighlightKind::WRITE),
284 });
285 }
286 _ => {}
287 }
288 }
289
290 highlights.sort_by(cmp_highlight_range);
291 highlights
292 }
293
294 /// Highlight all occurrences of a standalone function name.
295 fn highlight_function(

Callers 1

Calls 3

byte_range_to_lsp_rangeFunction · 0.85
pushMethod · 0.80
var_def_kind_atMethod · 0.80

Tested by

no test coverage detected