@@ -12,6 +12,9 @@ import { createLSPClient, languages, getLanguage } from "../common.js";
12
12
import lint , { waitForDiagnostics } from "./lint.js" ;
13
13
import format , { formatting } from "./format.js" ;
14
14
15
+ import { setupRustProject , installRustLibraries } from "../langs/rust/rust.js" ;
16
+ import { targetPath } from "../langs/rust/Compiler.js" ;
17
+
15
18
Gtk . init ( ) ;
16
19
17
20
export async function main ( [ action , ...args ] ) {
@@ -399,51 +402,23 @@ async function ci({ filenames, current_dir }) {
399
402
400
403
const file_rust = demo_dir . get_child ( "code.rs" ) ;
401
404
if ( file_rust . query_exists ( null ) ) {
402
- print ( ` ${ file_rust . get_path ( ) } ` ) ;
403
-
404
- const uri = file_rust . get_uri ( ) ;
405
- const languageId = "rust" ;
406
- let version = 0 ;
407
-
408
- const [ contents ] = await file_rust . load_contents_async ( null ) ;
409
- const text = new TextDecoder ( ) . decode ( contents ) ;
410
-
411
- await lsp_clients . rust . _notify ( "textDocument/didOpen" , {
412
- textDocument : {
413
- uri,
414
- languageId,
415
- version : version ++ ,
416
- text,
417
- } ,
418
- } ) ;
419
-
420
- // FIXME: rust analyzer doesn't publish diagnostics if there are none
421
- // probably we should switch to pulling diagnostics but unknown if supported
422
- // https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification/#textDocument_pullDiagnostics
423
-
424
- // const diagnostics = await waitForDiagnostics({
425
- // uri,
426
- // lspc: lsp_clients.rust,
427
- // });
428
- // if (diagnostics.length > 0) {
429
- // printerr(serializeDiagnostics({ diagnostics }));
430
- // return false;
431
- // }
432
- // print(` ✅ lints`);
433
-
434
- const checks = await checkFile ( {
435
- lspc : lsp_clients . rust ,
436
- file : file_rust ,
437
- lang : getLanguage ( "rust" ) ,
438
- uri,
439
- } ) ;
405
+ await setupRustProject ( demo_dir ) ;
406
+ await installRustLibraries ( demo_dir ) ;
407
+ const cargo_launcher = new Gio . SubprocessLauncher ( ) ;
408
+ cargo_launcher . set_cwd ( demo_dir . get_path ( ) ) ;
409
+ const cargo = cargo_launcher . spawnv ( [
410
+ "cargo" ,
411
+ "clippy" ,
412
+ "--locked" ,
413
+ "--verbose" ,
414
+ "--target-dir" ,
415
+ targetPath ,
416
+ ] ) ;
417
+ await cargo . wait_async ( null ) ;
418
+
419
+ const checks = cargo . get_successful ( ) ;
420
+ cargo_launcher . close ( ) ;
440
421
if ( ! checks ) return false ;
441
-
442
- await lsp_clients . rust . _notify ( "textDocument/didClose" , {
443
- textDocument : {
444
- uri,
445
- } ,
446
- } ) ;
447
422
}
448
423
449
424
await Promise . all (
0 commit comments