@@ -81,9 +81,10 @@ defmodule ElixirLS.DebugAdapter.Server do
8181 def dbg ( { :|> , _meta , _args } = ast , options , % Macro.Env { } = env ) when is_list ( options ) do
8282 [ first_ast_chunk | asts_chunks ] = ast |> Macro . unpipe ( ) |> chunk_pipeline_asts_by_line ( env )
8383
84- initial_acc = [
84+ { first_line , _max_line } = line_range ( ast , env . line )
85+
86+ prelude =
8587 quote do
86- env = __ENV__
8788 options = unquote ( options )
8889
8990 options =
@@ -93,9 +94,6 @@ defmodule ElixirLS.DebugAdapter.Server do
9394 options
9495 end
9596
96- env = unquote ( env_with_line_from_asts ( first_ast_chunk ) )
97-
98- next? = unquote ( __MODULE__ ) . __next__ ( true , binding ( ) , env )
9997 value = unquote ( pipe_chunk_of_asts ( first_ast_chunk ) )
10098
10199 unquote ( __MODULE__ ) . __dbg_pipe_step__ (
@@ -105,16 +103,12 @@ defmodule ElixirLS.DebugAdapter.Server do
105103 options
106104 )
107105 end
108- ]
109106
110- for asts_chunk <- asts_chunks , reduce: initial_acc do
111- ast_acc ->
107+ main_block =
108+ for asts_chunk <- asts_chunks do
112109 piped_asts = pipe_chunk_of_asts ( [ { quote ( do: value ) , _index = 0 } ] ++ asts_chunk )
113110
114111 quote do
115- unquote ( ast_acc )
116- env = unquote ( env_with_line_from_asts ( asts_chunk ) )
117- next? = unquote ( __MODULE__ ) . __next__ ( next? , binding ( ) , env )
118112 value = unquote ( piped_asts )
119113
120114 unquote ( __MODULE__ ) . __dbg_pipe_step__ (
@@ -124,7 +118,9 @@ defmodule ElixirLS.DebugAdapter.Server do
124118 options
125119 )
126120 end
127- end
121+ end
122+
123+ annotate_quoted ( { :__block__ , [ ] , [ prelude | main_block ] } , true , % { env | line: first_line } )
128124 end
129125
130126 def dbg ( code , options , % Macro.Env { } = caller ) do
@@ -3310,22 +3306,6 @@ defmodule ElixirLS.DebugAdapter.Server do
33103306 defp unwrap_block ( { :__block__ , _ , exprs } , acc ) , do: Enum . reduce ( exprs , acc , & unwrap_block / 2 )
33113307 defp unwrap_block ( expr , acc ) , do: [ expr | acc ]
33123308
3313- defp env_with_line_from_asts ( asts ) do
3314- line =
3315- Enum . find_value ( asts , fn
3316- { { _fun_or_var , meta , _args } , _pipe_index } -> meta [ :line ]
3317- { _ast , _pipe_index } -> nil
3318- end )
3319-
3320- if line do
3321- quote do
3322- % { env | line: unquote ( line ) }
3323- end
3324- else
3325- quote do: env
3326- end
3327- end
3328-
33293309 defp handle_request_async ( packet , start_time , func ) do
33303310 parent = self ( )
33313311
0 commit comments