@@ -120,7 +120,7 @@ defmodule NextLS.Runtime do
120
120
NextLS.Logger . log ( logger , "The runtime for #{ name } has successfully shutdown." )
121
121
122
122
reason ->
123
- NextLS.Logger . error ( logger , "The runtime for #{ name } has crashed with reason: #{ reason } ." )
123
+ NextLS.Logger . error ( logger , "The runtime for #{ name } has crashed with reason: #{ inspect ( reason ) } ." )
124
124
end
125
125
end
126
126
end )
@@ -136,8 +136,8 @@ defmodule NextLS.Runtime do
136
136
|> Path . join ( "monkey/_next_ls_private_compiler.ex" )
137
137
|> then ( & :rpc . call ( node , Code , :compile_file , [ & 1 ] ) )
138
138
|> tap ( fn
139
- { :badrpc , :EXIT , { error , _ } } ->
140
- NextLS.Logger . error ( logger , error )
139
+ { :badrpc , error } ->
140
+ NextLS.Logger . error ( logger , { :badrpc , error } )
141
141
142
142
_ ->
143
143
:ok
@@ -192,15 +192,16 @@ defmodule NextLS.Runtime do
192
192
def handle_call ( :compile , from , % { node: node } = state ) do
193
193
task =
194
194
Task.Supervisor . async_nolink ( state . task_supervisor , fn ->
195
- { _ , errors } = :rpc . call ( node , :_next_ls_private_compiler , :compile , [ ] )
195
+ case :rpc . call ( node , :_next_ls_private_compiler , :compile , [ ] ) do
196
+ { :badrpc , error } ->
197
+ NextLS.Logger . error ( state . logger , { :badrpc , error } )
196
198
197
- Registry . dispatch ( state . registry , :extensions , fn entries ->
198
- for { pid , _ } <- entries do
199
- send ( pid , { :compiler , errors } )
200
- end
201
- end )
199
+ { _ , [ _ | _ ] = diagnostics } ->
200
+ dispatch_to_extensions ( state , { :compiler , diagnostics } )
202
201
203
- errors
202
+ _ ->
203
+ :ok
204
+ end
204
205
end )
205
206
206
207
{ :noreply , % { state | compiler_ref: % { task . ref => from } } }
@@ -248,4 +249,10 @@ defmodule NextLS.Runtime do
248
249
true
249
250
end
250
251
end
252
+
253
+ defp dispatch_to_extensions ( state , message ) do
254
+ Registry . dispatch ( state . registry , :extensions , fn entries ->
255
+ for { pid , _ } <- entries , do: send ( pid , message )
256
+ end )
257
+ end
251
258
end
0 commit comments