Skip to content

Commit ba9f5e3

Browse files
committed
Remove dependency on interface types from jumpToLocation
1 parent aa87fa8 commit ba9f5e3

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

extensions/ql-vscode/src/compare/compare-view.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ export class CompareView extends AbstractWebview<
130130
break;
131131

132132
case "viewSourceFile":
133-
await jumpToLocation(msg, this.databaseManager, this.logger);
133+
await jumpToLocation(
134+
msg.databaseUri,
135+
msg.loc,
136+
this.databaseManager,
137+
this.logger,
138+
);
134139
break;
135140

136141
case "openQuery":

extensions/ql-vscode/src/databases/local-databases/locations.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
isLineColumnLoc,
2020
tryGetResolvableLocation,
2121
} from "../../pure/bqrs-utils";
22-
import { ViewSourceFileMsg } from "../../pure/interface-types";
22+
import { getErrorMessage } from "../../pure/helpers-pure";
2323
import { Logger } from "../../common";
2424
import { DatabaseItem } from "./database-item";
2525
import { DatabaseManager } from "./database-manager";
@@ -139,27 +139,22 @@ export async function showLocation(location?: Location) {
139139
}
140140

141141
export async function jumpToLocation(
142-
msg: ViewSourceFileMsg,
142+
databaseUri: string,
143+
loc: ResolvableLocationValue,
143144
databaseManager: DatabaseManager,
144145
logger: Logger,
145146
) {
146-
const databaseItem = databaseManager.findDatabaseItem(
147-
Uri.parse(msg.databaseUri),
148-
);
147+
const databaseItem = databaseManager.findDatabaseItem(Uri.parse(databaseUri));
149148
if (databaseItem !== undefined) {
150149
try {
151-
await showResolvableLocation(msg.loc, databaseItem);
150+
await showResolvableLocation(loc, databaseItem);
152151
} catch (e) {
153-
if (e instanceof Error) {
154-
if (e.message.match(/File not found/)) {
155-
void Window.showErrorMessage(
156-
"Original file of this result is not in the database's source archive.",
157-
);
158-
} else {
159-
void logger.log(`Unable to handleMsgFromView: ${e.message}`);
160-
}
152+
if (e instanceof Error && e.message.match(/File not found/)) {
153+
void Window.showErrorMessage(
154+
"Original file of this result is not in the database's source archive.",
155+
);
161156
} else {
162-
void logger.log(`Unable to handleMsgFromView: ${e}`);
157+
void logger.log(`Unable to jump to location: ${getErrorMessage(e)}`);
163158
}
164159
}
165160
}

extensions/ql-vscode/src/interface.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,12 @@ export class ResultsView extends AbstractWebview<
258258
this.onWebViewLoaded();
259259
break;
260260
case "viewSourceFile": {
261-
await jumpToLocation(msg, this.databaseManager, this.logger);
261+
await jumpToLocation(
262+
msg.databaseUri,
263+
msg.loc,
264+
this.databaseManager,
265+
this.logger,
266+
);
262267
break;
263268
}
264269
case "toggleDiagnostics": {

0 commit comments

Comments
 (0)