Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 54x 49x 36x 9x | import type { SourceLocation } from "@shared/source-project";
/** A parser location, with a numeric form kept for legacy single-file callers. */
export type SourceNavigationTarget = SourceLocation | number;
export function isSourceLocation(
target: SourceNavigationTarget,
): target is SourceLocation {
return typeof target === "object" && target !== null;
}
export function isNavigableSourceTarget(
target: SourceNavigationTarget | undefined,
): target is SourceNavigationTarget {
if (target === undefined) return false;
return isSourceLocation(target) ? target.line > 0 : target > 0;
}
export function formatSourceNavigationTarget(
target: SourceNavigationTarget,
): string {
return isSourceLocation(target) ? `${target.file}:${target.line}` : `Line ${target}`;
}
|