Resolve `@see` references to file locations where possible. For each raw `@see` string, attempts to resolve symbol references (class names, `Class::member()`, `Class::$prop`) to a `file://` URI with a line fragment so that the hover popup renders them as clickable links. URLs and unresolvable symbols get `None`.
(
&self,
see_refs: &[String],
uri: &str,
content: &str,
)
| 320 | /// URI with a line fragment so that the hover popup renders them as |
| 321 | /// clickable links. URLs and unresolvable symbols get `None`. |
| 322 | pub(crate) fn resolve_see_refs( |
| 323 | &self, |
| 324 | see_refs: &[String], |
| 325 | uri: &str, |
| 326 | content: &str, |
| 327 | ) -> Vec<ResolvedSeeRef> { |
| 328 | see_refs |
| 329 | .iter() |
| 330 | .map(|raw| { |
| 331 | // Extract the first token (the symbol or URL). |
| 332 | let target = raw |
| 333 | .split_once(|c: char| c.is_whitespace()) |
| 334 | .map(|(t, _)| t.trim()) |
| 335 | .unwrap_or(raw.as_str()); |
| 336 | |
| 337 | // URLs don't need resolution. |
| 338 | if target.starts_with("http://") || target.starts_with("https://") { |
| 339 | return ResolvedSeeRef { |
| 340 | raw: raw.clone(), |
| 341 | location_uri: None, |
| 342 | }; |
| 343 | } |
| 344 | |
| 345 | // Try to resolve as a class or class::member reference. |
| 346 | let location_uri = self.resolve_see_target(target, uri, content); |
| 347 | |
| 348 | ResolvedSeeRef { |
| 349 | raw: raw.clone(), |
| 350 | location_uri, |
| 351 | } |
| 352 | }) |
| 353 | .collect() |
| 354 | } |
| 355 | |
| 356 | /// Resolve a single `@see` target to a `file://` URI with line fragment. |
| 357 | /// |
no test coverage detected