@@ -151,6 +151,8 @@ function META:Recompile(path, lol, diagnostics)
151151 if not lol then
152152 if type (cfg .lsp .entry_point ) == " table" then
153153 if self .debug then print (" recompiling entry points from: " .. path ) end
154+ local ok = true
155+ local reasons = {}
154156
155157 for _ , path in ipairs (cfg .lsp .entry_point ) do
156158 local new_path = path_util .Resolve (path , cfg .parser .root_directory , cfg .parser .working_directory )
@@ -160,10 +162,14 @@ function META:Recompile(path, lol, diagnostics)
160162 table .print (cfg )
161163 end
162164
163- self :Recompile (new_path , true , diagnostics )
165+ local b , reason = self :Recompile (new_path , true , diagnostics )
166+ if not b then
167+ ok = false
168+ table.insert (reasons , reason )
169+ end
164170 end
165171
166- return
172+ return ok , table.concat ( reasons , " \n " )
167173 elseif type (cfg .lsp .entry_point ) == " string" then
168174 local path = path_util .Resolve (cfg .lsp .entry_point , cfg .parser .root_directory , cfg .parser .working_directory )
169175
@@ -172,15 +178,14 @@ function META:Recompile(path, lol, diagnostics)
172178 print (cfg .lsp .entry_point , " ->" , path )
173179 table .print (cfg )
174180 end
175-
176- self :Recompile (path , true , diagnostics )
177- return
181+
182+ return self :Recompile (path , true , diagnostics )
178183 end
179184 end
180185
181186 local entry_point = path or cfg .lsp .entry_point
182187
183- if not entry_point then return false end
188+ if not entry_point then return false , " no entry point " end
184189
185190 cfg .parser .pre_read_file = function (parser , path )
186191 if self .TempFiles [path ] then return self :GetFileContent (path ) end
@@ -202,14 +207,14 @@ function META:Recompile(path, lol, diagnostics)
202207 local compiler = Compiler ([[ return import("]] .. entry_point .. [[ ")]] , entry_point , cfg )
203208 compiler .debug = true
204209 compiler :SetEnvironments (runtime_env , typesystem_env )
205-
210+ print ( path , " COMPILER CREATED " )
206211 function compiler .OnDiagnostic (_ , code , msg , severity , start , stop , node , ...)
212+ print (" ON DIAGNOSTIC" , name , code , msg , severity , start , stop , node , ... )
207213 local name = code :GetName ()
208-
214+
209215 if severity == " fatal" then
210216 self :DebugLog (" [ " .. entry_point .. " ] " .. formating .FormatMessage (msg , ... ))
211217 end
212-
213218 diagnostics [name ] = diagnostics [name ] or {}
214219 table.insert (
215220 diagnostics [name ],
@@ -224,7 +229,11 @@ function META:Recompile(path, lol, diagnostics)
224229 )
225230 end
226231
227- if compiler :Parse () then
232+ local ok , err = compiler :Parse ()
233+ if not ok then
234+ print (" FAILED TO PARSE" , path , err )
235+ end
236+ if ok then
228237 self :DebugLog (" [ " .. entry_point .. " ] parsed with " .. # compiler .Tokens .. " tokens" )
229238
230239 if compiler .SyntaxTree .imports then
@@ -301,14 +310,19 @@ function META:Recompile(path, lol, diagnostics)
301310 for name , data in pairs (diagnostics ) do
302311 self :OnDiagnostics (name , data )
303312 end
313+
314+ return true
304315end
305316
306317function META :OnDiagnostics (name , data ) end
307318
308319function META :OnResponse (response ) end
309320
310321function META :Initialize ()
311- self :Recompile ()
322+ local ok , reason = self :Recompile ()
323+ if not ok then
324+ print (" failed to recompile without path: " .. reason )
325+ end
312326end
313327
314328function META :Format (code , path )
331345
332346function META :OpenFile (path , code )
333347 self :SetFileContent (path , code )
334- self :Recompile (path )
348+ assert ( self :Recompile (path ) )
335349end
336350
337351function META :CloseFile (path )
@@ -341,12 +355,12 @@ end
341355
342356function META :UpdateFile (path , code )
343357 self :SetFileContent (path , code )
344- self :Recompile (path )
358+ assert ( self :Recompile (path ) )
345359end
346360
347361function META :SaveFile (path )
348362 self :SetFileContent (path , nil )
349- self :Recompile (path )
363+ assert ( self :Recompile (path ) )
350364end
351365
352366function META :GetAllTokens (path )
0 commit comments