@@ -37,11 +37,12 @@ export const shownLocationLineDecoration =
3737/**
3838 * Resolves the specified CodeQL location to a URI into the source archive.
3939 * @param loc CodeQL location to resolve. Must have a non-empty value for `loc.file`.
40- * @param databaseItem Database in which to resolve the file location.
40+ * @param databaseItem Database in which to resolve the file location, or `undefined` to resolve
41+ * from the local file system.
4142 */
4243function resolveFivePartLocation (
4344 loc : UrlValueLineColumnLocation ,
44- databaseItem : DatabaseItem ,
45+ databaseItem : DatabaseItem | undefined ,
4546) : Location {
4647 // `Range` is a half-open interval, and is zero-based. CodeQL locations are closed intervals, and
4748 // are one-based. Adjust accordingly.
@@ -52,7 +53,10 @@ function resolveFivePartLocation(
5253 Math . max ( 1 , loc . endColumn ) ,
5354 ) ;
5455
55- return new Location ( databaseItem . resolveSourceFile ( loc . uri ) , range ) ;
56+ return new Location (
57+ databaseItem ?. resolveSourceFile ( loc . uri ) ?? Uri . parse ( loc . uri ) ,
58+ range ,
59+ ) ;
5660}
5761
5862/**
@@ -62,22 +66,26 @@ function resolveFivePartLocation(
6266 */
6367function resolveWholeFileLocation (
6468 loc : UrlValueWholeFileLocation ,
65- databaseItem : DatabaseItem ,
69+ databaseItem : DatabaseItem | undefined ,
6670) : Location {
6771 // A location corresponding to the start of the file.
6872 const range = new Range ( 0 , 0 , 0 , 0 ) ;
69- return new Location ( databaseItem . resolveSourceFile ( loc . uri ) , range ) ;
73+ return new Location (
74+ databaseItem ?. resolveSourceFile ( loc . uri ) ?? Uri . parse ( loc . uri ) ,
75+ range ,
76+ ) ;
7077}
7178
7279/**
7380 * Try to resolve the specified CodeQL location to a URI into the source archive. If no exact location
7481 * can be resolved, returns `undefined`.
7582 * @param loc CodeQL location to resolve
76- * @param databaseItem Database in which to resolve the file location.
83+ * @param databaseItem Database in which to resolve the file location, or `undefined` to resolve
84+ * from the local file system.
7785 */
7886export function tryResolveLocation (
7987 loc : UrlValueResolvable | undefined ,
80- databaseItem : DatabaseItem ,
88+ databaseItem : DatabaseItem | undefined ,
8189) : Location | undefined {
8290 if ( ! loc ) {
8391 return ;
@@ -95,7 +103,7 @@ export function tryResolveLocation(
95103
96104export async function showResolvableLocation (
97105 loc : UrlValueResolvable ,
98- databaseItem : DatabaseItem ,
106+ databaseItem : DatabaseItem | undefined ,
99107 logger : Logger ,
100108) : Promise < void > {
101109 try {
@@ -151,13 +159,14 @@ export async function showLocation(location?: Location) {
151159}
152160
153161export async function jumpToLocation (
154- databaseUri : string ,
162+ databaseUri : string | undefined ,
155163 loc : UrlValueResolvable ,
156164 databaseManager : DatabaseManager ,
157165 logger : Logger ,
158166) {
159- const databaseItem = databaseManager . findDatabaseItem ( Uri . parse ( databaseUri ) ) ;
160- if ( databaseItem !== undefined ) {
161- await showResolvableLocation ( loc , databaseItem , logger ) ;
162- }
167+ const databaseItem =
168+ databaseUri !== undefined
169+ ? databaseManager . findDatabaseItem ( Uri . parse ( databaseUri ) )
170+ : undefined ;
171+ await showResolvableLocation ( loc , databaseItem , logger ) ;
163172}
0 commit comments