@@ -37,11 +37,12 @@ export const shownLocationLineDecoration =
37
37
/**
38
38
* Resolves the specified CodeQL location to a URI into the source archive.
39
39
* @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.
41
42
*/
42
43
function resolveFivePartLocation (
43
44
loc : UrlValueLineColumnLocation ,
44
- databaseItem : DatabaseItem ,
45
+ databaseItem : DatabaseItem | undefined ,
45
46
) : Location {
46
47
// `Range` is a half-open interval, and is zero-based. CodeQL locations are closed intervals, and
47
48
// are one-based. Adjust accordingly.
@@ -52,7 +53,10 @@ function resolveFivePartLocation(
52
53
Math . max ( 1 , loc . endColumn ) ,
53
54
) ;
54
55
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
+ ) ;
56
60
}
57
61
58
62
/**
@@ -62,22 +66,26 @@ function resolveFivePartLocation(
62
66
*/
63
67
function resolveWholeFileLocation (
64
68
loc : UrlValueWholeFileLocation ,
65
- databaseItem : DatabaseItem ,
69
+ databaseItem : DatabaseItem | undefined ,
66
70
) : Location {
67
71
// A location corresponding to the start of the file.
68
72
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
+ ) ;
70
77
}
71
78
72
79
/**
73
80
* Try to resolve the specified CodeQL location to a URI into the source archive. If no exact location
74
81
* can be resolved, returns `undefined`.
75
82
* @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.
77
85
*/
78
86
export function tryResolveLocation (
79
87
loc : UrlValueResolvable | undefined ,
80
- databaseItem : DatabaseItem ,
88
+ databaseItem : DatabaseItem | undefined ,
81
89
) : Location | undefined {
82
90
if ( ! loc ) {
83
91
return ;
@@ -95,7 +103,7 @@ export function tryResolveLocation(
95
103
96
104
export async function showResolvableLocation (
97
105
loc : UrlValueResolvable ,
98
- databaseItem : DatabaseItem ,
106
+ databaseItem : DatabaseItem | undefined ,
99
107
logger : Logger ,
100
108
) : Promise < void > {
101
109
try {
@@ -151,13 +159,14 @@ export async function showLocation(location?: Location) {
151
159
}
152
160
153
161
export async function jumpToLocation (
154
- databaseUri : string ,
162
+ databaseUri : string | undefined ,
155
163
loc : UrlValueResolvable ,
156
164
databaseManager : DatabaseManager ,
157
165
logger : Logger ,
158
166
) {
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 ) ;
163
172
}
0 commit comments