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

Function format_see_refs

src/hover/formatting.rs:407–438  ·  view source on GitHub ↗

Format `@see` references as hover lines. URL references are rendered as clickable markdown links. Symbol references with a resolved location are rendered as clickable file links that jump to the definition site. Unresolved symbols are rendered as inline code. Each entry becomes a separate line in the hover popup.

(
    see_refs: &[ResolvedSeeRef],
    existing_links: &[String],
    lines: &mut Vec<String>,
)

Source from the content-addressed store, hash-verified

405/// rendered as inline code.
406/// Each entry becomes a separate line in the hover popup.
407pub(super) fn format_see_refs(
408 see_refs: &[ResolvedSeeRef],
409 existing_links: &[String],
410 lines: &mut Vec<String>,
411) {
412 for entry in see_refs {
413 // Split into the first token (symbol or URL) and optional description.
414 let (target, description) = match entry.raw.split_once(|c: char| c.is_whitespace()) {
415 Some((t, d)) => (t.trim(), Some(d.trim())),
416 None => (entry.raw.as_str(), None),
417 };
418
419 let desc_suffix = description.map(|d| format!(" {}", d)).unwrap_or_default();
420
421 if target.starts_with("http://") || target.starts_with("https://") {
422 // Skip URL references that already appear as @link entries.
423 if existing_links.iter().any(|l| l == target) {
424 continue;
425 }
426 // URL reference — render as a clickable markdown link,
427 // same style as @link.
428 lines.push(format!("[{}]({}){}", target, target, desc_suffix));
429 } else if let Some(ref uri) = entry.location_uri {
430 // Symbol reference with resolved location — render as a
431 // clickable link that opens the file at the definition line.
432 lines.push(format!("[`{}`]({}){}", target, uri, desc_suffix));
433 } else {
434 // Symbol reference without a known location — inline code.
435 lines.push(format!("`{}`{}", target, desc_suffix));
436 }
437 }
438}
439
440/// Extract the trailing description from a `@var` tag in a pre-parsed
441/// [`DocblockInfo`].

Callers 3

hover_for_methodMethod · 0.85
hover_for_class_infoMethod · 0.85
hover_for_functionFunction · 0.85

Calls 4

as_strMethod · 0.80
iterMethod · 0.80
pushMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected