resolveSourceUrl

fun resolveSourceUrl(absoluteFile: String?, relativePath: String?, fileLine: Int, contexts: List<CodeBrowserUrl.Context>): String?

Multi-repo resolution shared by every source-link producer (the diagram enrichment, the function-metrics report, the descriptions report) so a file resolves to the same link everywhere. Two strategies, in order:

  1. Absolute-path prefix — pick the Context whose gitRoot is the deepest prefix of absoluteFile (handles nested repos / a repo inside another checkout). This is the common case once the analyzer reports an on-disk absolute path.

  2. Relative-path probe — when no absolute match, try <gitRoot>/<relativePath> in each repo; first existing file wins. Skips blank / /usr… / bazel-out/… paths that can't be tracked source.

Returns null when nothing matches (caller renders the location without a link). Empty contexts ⇒ always null.

Generated with STIG