@@ -5,51 +5,37 @@ import Gtk from "gi://Gtk";
55import { getLanguage } from "../common.js" ;
66import { parse } from "../langs/xml/xml.js" ;
77import { LSPError } from "../lsp/LSP.js" ;
8- import { waitForDiagnostics } from "./lint.js" ;
9- import { serializeDiagnostics , checkFile } from "./util.js" ;
10-
11- export default async function blueprint ( { file_blueprint, lsp_clients } ) {
12- print ( ` ${ file_blueprint . get_path ( ) } ` ) ;
13- const uri = file_blueprint . get_uri ( ) ;
14- const languageId = "blueprint" ;
15- let version = 0 ;
16-
17- const [ contents ] = await file_blueprint . load_contents_async ( null ) ;
18- const text = new TextDecoder ( ) . decode ( contents ) ;
19-
20- await lsp_clients . blueprint . _notify ( "textDocument/didOpen" , {
21- textDocument : {
22- uri,
23- languageId,
24- version : version ++ ,
25- text,
8+ import { checkFile , diagnose } from "./util.js" ;
9+
10+ const languageId = "blueprint" ;
11+
12+ export default async function blueprint ( { file, lspc } ) {
13+ print ( ` ${ file . get_path ( ) } ` ) ;
14+
15+ const text = await diagnose ( {
16+ file,
17+ lspc,
18+ languageId,
19+ filter ( diagnostic ) {
20+ // No replacements yet
21+ return ! [
22+ "Gtk.ShortcutsShortcut is deprecated\nhint: This widget will be removed in GTK 5" ,
23+ "Gtk.ShortcutLabel is deprecated\nhint: This widget will be removed in GTK 5" ,
24+ ] . includes ( diagnostic . message ) ;
2625 } ,
2726 } ) ;
27+ if ( text === false ) return false ;
2828
29- const diagnostics = await waitForDiagnostics ( {
30- uri,
31- lspc : lsp_clients . blueprint ,
32- } ) ;
33- if ( diagnostics . length > 0 ) {
34- printerr ( serializeDiagnostics ( { diagnostics } ) ) ;
35- return false ;
36- }
37-
38- print ( ` ✅ lints` ) ;
39-
40- const { xml } = await lsp_clients . blueprint . _request (
41- "textDocument/x-blueprint-compile" ,
42- {
43- textDocument : {
44- uri,
45- } ,
29+ const { xml } = await lspc . _request ( "textDocument/x-blueprint-compile" , {
30+ textDocument : {
31+ uri : file . get_uri ( ) ,
4632 } ,
47- ) ;
33+ } ) ;
4834
4935 print ( ` ✅ compiles` ) ;
5036
5137 try {
52- await lsp_clients . blueprint . _request ( "x-blueprint/decompile" , {
38+ await lspc . _request ( "x-blueprint/decompile" , {
5339 text : xml ,
5440 } ) ;
5541 print ( " ✅ decompiles" ) ;
@@ -68,16 +54,16 @@ export default async function blueprint({ file_blueprint, lsp_clients }) {
6854 }
6955
7056 const checks = await checkFile ( {
71- lspc : lsp_clients . blueprint ,
72- file : file_blueprint ,
73- lang : getLanguage ( "blueprint" ) ,
74- uri,
57+ lspc,
58+ file,
59+ lang : getLanguage ( languageId ) ,
60+ uri : file . get_uri ( ) ,
7561 } ) ;
7662 if ( ! checks ) return false ;
7763
78- await lsp_clients . blueprint . _notify ( "textDocument/didClose" , {
64+ await lspc . _notify ( "textDocument/didClose" , {
7965 textDocument : {
80- uri,
66+ uri : file . get_uri ( ) ,
8167 } ,
8268 } ) ;
8369
0 commit comments