( source: SourceLocation, format: "path" | "vscode" = "path" )
| 737 | * ``` |
| 738 | */ |
| 739 | export function formatSourceLocation( |
| 740 | source: SourceLocation, |
| 741 | format: "path" | "vscode" = "path" |
| 742 | ): string { |
| 743 | const { fileName, lineNumber, columnNumber } = source; |
| 744 | |
| 745 | // Build line:column suffix |
| 746 | let location = `${fileName}:${lineNumber}`; |
| 747 | if (columnNumber !== undefined) { |
| 748 | location += `:${columnNumber}`; |
| 749 | } |
| 750 | |
| 751 | if (format === "vscode") { |
| 752 | // VSCode can open files via URL protocol |
| 753 | // Assumes fileName is absolute or can be resolved |
| 754 | return `vscode://file${fileName.startsWith("/") ? "" : "/"}${location}`; |
| 755 | } |
| 756 | |
| 757 | return location; |
| 758 | } |
| 759 | |
| 760 | /** |
| 761 | * Gets source locations for multiple elements at once |
no outgoing calls
no test coverage detected
searching dependent graphs…