1- import { CancellationTokenSource , ExtensionContext , ViewColumn } from "vscode" ;
1+ import {
2+ CancellationTokenSource ,
3+ ExtensionContext ,
4+ ViewColumn ,
5+ window ,
6+ } from "vscode" ;
27import { AbstractWebview , WebviewPanelConfig } from "../abstract-webview" ;
38import {
49 FromDataExtensionsEditorMessage ,
@@ -14,6 +19,9 @@ import { dump } from "js-yaml";
1419import { getOnDiskWorkspaceFolders } from "../helpers" ;
1520import { DatabaseItem } from "../local-databases" ;
1621import { CodeQLCliServer } from "../cli" ;
22+ import { assertNever } from "../pure/helpers-pure" ;
23+ import { ResolvableLocationValue } from "../pure/bqrs-cli-types" ;
24+ import { showResolvableLocation } from "../interface-utils" ;
1725
1826export class DataExtensionsEditorView extends AbstractWebview <
1927 ToDataExtensionsEditorMessage ,
@@ -57,9 +65,13 @@ export class DataExtensionsEditorView extends AbstractWebview<
5765 case "viewLoaded" :
5866 await this . onWebViewLoaded ( ) ;
5967
68+ break ;
69+ case "jumpToUsage" :
70+ await this . jumpToUsage ( msg . location ) ;
71+
6072 break ;
6173 default :
62- throw new Error ( "Unexpected message type" ) ;
74+ assertNever ( msg ) ;
6375 }
6476 }
6577
@@ -69,6 +81,26 @@ export class DataExtensionsEditorView extends AbstractWebview<
6981 await this . loadExternalApiUsages ( ) ;
7082 }
7183
84+ protected async jumpToUsage (
85+ location : ResolvableLocationValue ,
86+ ) : Promise < void > {
87+ try {
88+ await showResolvableLocation ( location , this . databaseItem ) ;
89+ } catch ( e ) {
90+ if ( e instanceof Error ) {
91+ if ( e . message . match ( / F i l e n o t f o u n d / ) ) {
92+ void window . showErrorMessage (
93+ "Original file of this result is not in the database's source archive." ,
94+ ) ;
95+ } else {
96+ void extLogger . log ( `Unable to handleMsgFromView: ${ e . message } ` ) ;
97+ }
98+ } else {
99+ void extLogger . log ( `Unable to handleMsgFromView: ${ e } ` ) ;
100+ }
101+ }
102+ }
103+
72104 protected async loadExternalApiUsages ( ) : Promise < void > {
73105 const queryResult = await this . runQuery ( ) ;
74106 if ( ! queryResult ) {
0 commit comments