CodeBrowserUrl

Builds provider-correct GitHub/GitLab source URLs from a local file + optional line number, given a code-browser configuration that pins the remote base URL, the git root, and the commit SHA to link against.

Extracted into a shared helper so the multiple call sites (com.stigway.engine.commands.analyzefunctiondescriptions.AnalyzeFunctionDescriptionsCommand, com.stigway.engine.commands.analyzefunctionmetrics.AnalyzeFunctionMetricsCommand, and the upcoming Gradle-side getSourceUrl callers) build links the same way.

Types

Link copied to clipboard
Link copied to clipboard
data class Context(val gitRoot: Path, val baseUrl: String, val commit: String, val remotePath: String = "", val codeBrowser: CodeBrowser = CodeBrowser.AUTO, val editRef: String? = null, val ideaOrigin: String = "")

Pin for one repository: a local git root, the remote base URL (without trailing slash; we trim defensively), and the commit SHA to resolve blob/… against.

Link copied to clipboard
data class ResolvedSourceUrl(val url: String, val codeBrowser: CodeBrowser)

Functions

Link copied to clipboard

Builds the provider-correct page for Context.commit.

fun buildCommitUrl(baseUrl: String, commit: String, codeBrowser: CodeBrowser = CodeBrowser.AUTO): String?

Builds the provider-correct commit page used by build provenance.

Link copied to clipboard
fun buildEditUrl(rootDir: Path, file: String, fileLine: Int, context: CodeBrowserUrl.Context): String?

Builds an editable source URL only when Context.editRef is available.

Link copied to clipboard
fun buildIdeaUrl(rootDir: Path, file: String, fileLine: Int, context: CodeBrowserUrl.Context): String?

Builds an IntelliJ IDEA navigation URI for a repository-owned source file. IDEA matches Context.baseUrl against open/recent projects and resolves the repository-relative path locally; no workstation path is published.

Link copied to clipboard

Builds the configured repository location, pinned to Context.commit when it maps to a subdirectory.

fun buildRepositoryRootUrl(baseUrl: String, ref: String, remotePath: String = "", codeBrowser: CodeBrowser = CodeBrowser.AUTO): String?

Builds the repository URL represented by baseUrl and remotePath. A repository root is linked directly; a configured subdirectory is linked at the same immutable ref used by source links.

Link copied to clipboard
fun buildRepositoryUrl(baseUrl: String, ref: String, relativePath: String, fileLine: Int = 0, remotePath: String = "", codeBrowser: CodeBrowser = CodeBrowser.AUTO, action: CodeBrowserUrl.Action = Action.VIEW): String?

Builds a source URL when the repository-relative path is already known.

Link copied to clipboard
fun buildSourceUrl(rootDir: Path, file: String, fileLine: Int, context: CodeBrowserUrl.Context): String?

Returns the <baseUrl>/blob/<commit>/<encoded-path>[#L<line>] URL for a local file, or null if the file isn't inside the git root (no link makes sense outside the tracked tree).

Link copied to clipboard
fun contextsFrom(roots: List<String>, remoteUrls: List<String>, commits: List<String>, remotePaths: List<String> = emptyList(), codeBrowsers: List<String> = emptyList(), editRefs: List<String> = emptyList(), ideaOrigins: List<String> = emptyList()): List<CodeBrowserUrl.Context>

Builds one Context per repo from index-aligned root / remote-URL / commit lists (the shape the Gradle tasks carry from repoLocations.dokkaRepoInfos). Entries with a blank root, URL or commit are dropped — they can't form a link.

Link copied to clipboard

URL-encode each /-separated path segment independently and rejoin. Spaces become %20 (not +); other special chars follow URLEncoder.encode(…, UTF-8).

Link copied to clipboard
fun resolveCodeBrowser(configured: CodeBrowser, remoteUrl: String): CodeBrowser
Link copied to clipboard
fun resolveEditLink(absoluteFile: String?, relativePath: String?, fileLine: Int, contexts: List<CodeBrowserUrl.Context>): CodeBrowserUrl.ResolvedSourceUrl?
Link copied to clipboard
fun resolveEditUrl(absoluteFile: String?, relativePath: String?, fileLine: Int, contexts: List<CodeBrowserUrl.Context>): String?
Link copied to clipboard
fun resolveIdeaUrl(absoluteFile: String?, relativePath: String?, fileLine: Int, contexts: List<CodeBrowserUrl.Context>): String?
Link copied to clipboard
fun resolveSourceLink(absoluteFile: String?, relativePath: String?, fileLine: Int, contexts: List<CodeBrowserUrl.Context>): CodeBrowserUrl.ResolvedSourceUrl?
Link copied to clipboard
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:

Generated with STIG