Remove dependency on interface types from jumpToLocation

This commit is contained in:
Koen Vlaswinkel
2023-06-06 11:27:57 +02:00
parent aa87fa8cda
commit ba9f5e35cb
3 changed files with 22 additions and 17 deletions

View File

@@ -130,7 +130,12 @@ export class CompareView extends AbstractWebview<
break;
case "viewSourceFile":
await jumpToLocation(msg, this.databaseManager, this.logger);
await jumpToLocation(
msg.databaseUri,
msg.loc,
this.databaseManager,
this.logger,
);
break;
case "openQuery":

View File

@@ -19,7 +19,7 @@ import {
isLineColumnLoc,
tryGetResolvableLocation,
} from "../../pure/bqrs-utils";
import { ViewSourceFileMsg } from "../../pure/interface-types";
import { getErrorMessage } from "../../pure/helpers-pure";
import { Logger } from "../../common";
import { DatabaseItem } from "./database-item";
import { DatabaseManager } from "./database-manager";
@@ -139,27 +139,22 @@ export async function showLocation(location?: Location) {
}
export async function jumpToLocation(
msg: ViewSourceFileMsg,
databaseUri: string,
loc: ResolvableLocationValue,
databaseManager: DatabaseManager,
logger: Logger,
) {
const databaseItem = databaseManager.findDatabaseItem(
Uri.parse(msg.databaseUri),
);
const databaseItem = databaseManager.findDatabaseItem(Uri.parse(databaseUri));
if (databaseItem !== undefined) {
try {
await showResolvableLocation(msg.loc, databaseItem);
await showResolvableLocation(loc, databaseItem);
} catch (e) {
if (e instanceof Error) {
if (e.message.match(/File not found/)) {
void Window.showErrorMessage(
"Original file of this result is not in the database's source archive.",
);
} else {
void logger.log(`Unable to handleMsgFromView: ${e.message}`);
}
if (e instanceof Error && e.message.match(/File not found/)) {
void Window.showErrorMessage(
"Original file of this result is not in the database's source archive.",
);
} else {
void logger.log(`Unable to handleMsgFromView: ${e}`);
void logger.log(`Unable to jump to location: ${getErrorMessage(e)}`);
}
}
}

View File

@@ -258,7 +258,12 @@ export class ResultsView extends AbstractWebview<
this.onWebViewLoaded();
break;
case "viewSourceFile": {
await jumpToLocation(msg, this.databaseManager, this.logger);
await jumpToLocation(
msg.databaseUri,
msg.loc,
this.databaseManager,
this.logger,
);
break;
}
case "toggleDiagnostics": {