1- import { commands , ExtensionContext , Uri , window } from "vscode" ;
1+ import { commands , Uri , window } from "vscode" ;
22import { CodeQLCliServer } from "./cli" ;
33import { QueryRunner } from "./queryRunner" ;
4- import { commandRunner } from "./commandRunner" ;
54import { basename , join } from "path" ;
65import { getErrorMessage } from "./pure/helpers-pure" ;
76import { redactableError } from "./pure/errors" ;
87import { showAndLogExceptionWithTelemetry } from "./helpers" ;
8+ import { QueryEditorCommands } from "./common/commands" ;
99
1010type QueryEditorOptions = {
1111 queryRunner : QueryRunner ;
@@ -14,41 +14,23 @@ type QueryEditorOptions = {
1414 qhelpTmpDir : string ;
1515} ;
1616
17- export function registerQueryEditorCommands (
18- ctx : ExtensionContext ,
19- { queryRunner, cliServer, qhelpTmpDir } : QueryEditorOptions ,
20- ) {
21- ctx . subscriptions . push (
22- commandRunner ( "codeQL.openReferencedFile" , async ( selectedQuery : Uri ) => {
23- await openReferencedFile ( queryRunner , cliServer , selectedQuery ) ;
24- } ) ,
25- ) ;
17+ export function getQueryEditorCommands ( {
18+ queryRunner,
19+ cliServer,
20+ qhelpTmpDir,
21+ } : QueryEditorOptions ) : QueryEditorCommands {
22+ const openReferencedFileCommand = async ( selectedQuery : Uri ) =>
23+ await openReferencedFile ( queryRunner , cliServer , selectedQuery ) ;
2624
27- // Since we are tracking extension usage through commands, this command mirrors the "codeQL.openReferencedFile" command
28- ctx . subscriptions . push (
29- commandRunner (
30- "codeQL.openReferencedFileContextEditor" ,
31- async ( selectedQuery : Uri ) => {
32- await openReferencedFile ( queryRunner , cliServer , selectedQuery ) ;
33- } ,
34- ) ,
35- ) ;
36-
37- // Since we are tracking extension usage through commands, this command mirrors the "codeQL.openReferencedFile" command
38- ctx . subscriptions . push (
39- commandRunner (
40- "codeQL.openReferencedFileContextExplorer" ,
41- async ( selectedQuery : Uri ) => {
42- await openReferencedFile ( queryRunner , cliServer , selectedQuery ) ;
43- } ,
44- ) ,
45- ) ;
46-
47- ctx . subscriptions . push (
48- commandRunner ( "codeQL.previewQueryHelp" , async ( selectedQuery : Uri ) => {
49- await previewQueryHelp ( cliServer , qhelpTmpDir , selectedQuery ) ;
50- } ) ,
51- ) ;
25+ return {
26+ "codeQL.openReferencedFile" : openReferencedFileCommand ,
27+ // Since we are tracking extension usage through commands, this command mirrors the "codeQL.openReferencedFile" command
28+ "codeQL.openReferencedFileContextEditor" : openReferencedFileCommand ,
29+ // Since we are tracking extension usage through commands, this command mirrors the "codeQL.openReferencedFile" command
30+ "codeQL.openReferencedFileContextExplorer" : openReferencedFileCommand ,
31+ "codeQL.previewQueryHelp" : async ( selectedQuery : Uri ) =>
32+ await previewQueryHelp ( cliServer , qhelpTmpDir , selectedQuery ) ,
33+ } ;
5234}
5335
5436async function previewQueryHelp (
0 commit comments