11import * as vscode from 'vscode' ;
22import * as lc from 'vscode-languageclient' ;
3+ import * as ra from '../rust-analyzer-api' ;
34
45import { Ctx , Cmd } from '../ctx' ;
56
@@ -14,16 +15,13 @@ export function run(ctx: Ctx): Cmd {
1415 const textDocument : lc . TextDocumentIdentifier = {
1516 uri : editor . document . uri . toString ( ) ,
1617 } ;
17- const params : RunnablesParams = {
18+
19+ const runnables = await client . sendRequest ( ra . runnables , {
1820 textDocument,
1921 position : client . code2ProtocolConverter . asPosition (
2022 editor . selection . active ,
2123 ) ,
22- } ;
23- const runnables = await client . sendRequest < Runnable [ ] > (
24- 'rust-analyzer/runnables' ,
25- params ,
26- ) ;
24+ } ) ;
2725 const items : RunnableQuickPick [ ] = [ ] ;
2826 if ( prevRunnable ) {
2927 items . push ( prevRunnable ) ;
@@ -48,7 +46,7 @@ export function run(ctx: Ctx): Cmd {
4846}
4947
5048export function runSingle ( ctx : Ctx ) : Cmd {
51- return async ( runnable : Runnable ) => {
49+ return async ( runnable : ra . Runnable ) => {
5250 const editor = ctx . activeRustEditor ;
5351 if ( ! editor ) return ;
5452
@@ -64,26 +62,13 @@ export function runSingle(ctx: Ctx): Cmd {
6462 } ;
6563}
6664
67- interface RunnablesParams {
68- textDocument : lc . TextDocumentIdentifier ;
69- position ?: lc . Position ;
70- }
71-
72- interface Runnable {
73- label : string ;
74- bin : string ;
75- args : string [ ] ;
76- env : { [ index : string ] : string } ;
77- cwd ?: string ;
78- }
79-
8065class RunnableQuickPick implements vscode . QuickPickItem {
8166 public label : string ;
8267 public description ?: string | undefined ;
8368 public detail ?: string | undefined ;
8469 public picked ?: boolean | undefined ;
8570
86- constructor ( public runnable : Runnable ) {
71+ constructor ( public runnable : ra . Runnable ) {
8772 this . label = runnable . label ;
8873 }
8974}
@@ -96,7 +81,7 @@ interface CargoTaskDefinition extends vscode.TaskDefinition {
9681 env ?: { [ key : string ] : string } ;
9782}
9883
99- function createTask ( spec : Runnable ) : vscode . Task {
84+ function createTask ( spec : ra . Runnable ) : vscode . Task {
10085 const TASK_SOURCE = 'Rust' ;
10186 const definition : CargoTaskDefinition = {
10287 type : 'cargo' ,
0 commit comments