@@ -8,9 +8,9 @@ import Gio from "gi://Gio";
88import Gtk from "gi://Gtk" ;
99import Adw from "gi://Adw" ;
1010
11- import { createLSPClient , languages } from "../common.js" ;
11+ import { createLSPClient , languages , getLanguage } from "../common.js" ;
1212import lint , { waitForDiagnostics } from "./lint.js" ;
13- import format from "./format.js" ;
13+ import format , { formatting } from "./format.js" ;
1414
1515Gtk . init ( ) ;
1616
@@ -90,6 +90,27 @@ function createLSPClients({ root_uri }) {
9090 ) ;
9191}
9292
93+ async function checkFile ( { lspc, file, lang, uri } ) {
94+ const [ contents ] = await file . load_contents_async ( null ) ;
95+ const text = new TextDecoder ( ) . decode ( contents ) ;
96+ const buffer = new Gtk . TextBuffer ( { text } ) ;
97+
98+ const buffer_tmp = new Gtk . TextBuffer ( { text : buffer . text } ) ;
99+ await formatting ( { buffer : buffer_tmp , uri, lang, lspc } ) ;
100+
101+ if ( buffer_tmp . text === buffer . text ) {
102+ print ( ` ✅ checks` ) ;
103+ return true ;
104+ } else {
105+ printerr (
106+ ` ❌ formatting differs - open and run ${ file
107+ . get_parent ( )
108+ . get_basename ( ) } with Workbench to fix`,
109+ ) ;
110+ return false ;
111+ }
112+ }
113+
93114async function ci ( { filenames, current_dir } ) {
94115 for ( const filename of filenames ) {
95116 const demo_dir = Gio . File . new_for_path ( filename ) ;
@@ -158,7 +179,6 @@ async function ci({ filenames, current_dir }) {
158179 print ( ` ✅ compiles` ) ;
159180
160181 try {
161- // const { blp } =
162182 await lsp_clients . blueprint . _request ( "x-blueprint/decompile" , {
163183 text : xml ,
164184 } ) ;
@@ -175,14 +195,22 @@ async function ci({ filenames, current_dir }) {
175195 ) {
176196 throw err ;
177197 }
178-
179- await lsp_clients . blueprint . _notify ( "textDocument/didClose" , {
180- textDocument : {
181- uri,
182- } ,
183- } ) ;
184198 }
185199
200+ const checks = await checkFile ( {
201+ lspc : lsp_clients . blueprint ,
202+ file : file_blueprint ,
203+ lang : getLanguage ( "blueprint" ) ,
204+ uri,
205+ } ) ;
206+ if ( ! checks ) return false ;
207+
208+ await lsp_clients . blueprint . _notify ( "textDocument/didClose" , {
209+ textDocument : {
210+ uri,
211+ } ,
212+ } ) ;
213+
186214 const tree = parse ( xml ) ;
187215 const template_el = tree . getChild ( "template" ) ;
188216
@@ -223,9 +251,16 @@ async function ci({ filenames, current_dir }) {
223251 printerr ( serializeDiagnostics ( { diagnostics } ) ) ;
224252 return false ;
225253 }
226-
227254 print ( ` ✅ lints` ) ;
228255
256+ const checks = await checkFile ( {
257+ lspc : lsp_clients . css ,
258+ file : file_css ,
259+ lang : getLanguage ( "css" ) ,
260+ uri,
261+ } ) ;
262+ if ( ! checks ) return false ;
263+
229264 await lsp_clients . css . _notify ( "textDocument/didClose" , {
230265 textDocument : {
231266 uri,
@@ -261,9 +296,16 @@ async function ci({ filenames, current_dir }) {
261296 printerr ( serializeDiagnostics ( { diagnostics } ) ) ;
262297 return false ;
263298 }
264-
265299 print ( ` ✅ lints` ) ;
266300
301+ const checks = await checkFile ( {
302+ lspc : lsp_clients . javascript ,
303+ file : file_javascript ,
304+ lang : getLanguage ( "javascript" ) ,
305+ uri,
306+ } ) ;
307+ if ( ! checks ) return false ;
308+
267309 const js_object_ids = getCodeObjectIds ( text ) ;
268310 for ( const object_id of js_object_ids ) {
269311 if ( ! blueprint_object_ids . includes ( object_id ) ) {
@@ -341,9 +383,16 @@ async function ci({ filenames, current_dir }) {
341383 printerr ( serializeDiagnostics ( { diagnostics } ) ) ;
342384 return false ;
343385 }
344-
345386 print ( ` ✅ lints` ) ;
346387
388+ const checks = await checkFile ( {
389+ lspc : lsp_clients . vala ,
390+ file : file_vala ,
391+ lang : getLanguage ( "vala" ) ,
392+ uri,
393+ } ) ;
394+ if ( ! checks ) return false ;
395+
347396 await lsp_clients . vala . _notify ( "textDocument/didClose" , {
348397 textDocument : {
349398 uri,
0 commit comments