@@ -38,23 +38,23 @@ defmodule Gradient.AstData do
3838 "a"
3939 |> is_atom ( )
4040 end , __ENV__ . line } ,
41- { :block , 11 ,
41+ { :block , 22 ,
4242 [
43- { :call , 14 , { :remote , 14 , { :atom , 14 , :erlang } , { :atom , 14 , :is_atom } } ,
44- [ { :integer , 13 , 1 } ] } ,
45- { :call , 17 , { :remote , 17 , { :atom , 17 , :erlang } , { :atom , 17 , :is_atom } } ,
46- [ { :cons , 16 , { :integer , 16 , 49 } , { nil , 16 } } ] } ,
47- { :call , 20 , { :remote , 20 , { :atom , 20 , :erlang } , { :atom , 20 , :is_atom } } ,
48- [ { :atom , 19 , :ok } ] } ,
49- { :call , 23 , { :remote , 23 , { :atom , 23 , :erlang } , { :atom , 23 , :is_atom } } ,
43+ { :call , 24 , { :remote , 24 , { :atom , 24 , :erlang } , { :atom , 24 , :is_atom } } ,
44+ [ { :integer , 23 , 1 } ] } ,
45+ { :call , 27 , { :remote , 27 , { :atom , 27 , :erlang } , { :atom , 27 , :is_atom } } ,
46+ [ { :cons , 26 , { :integer , 26 , 49 } , { nil , 26 } } ] } ,
47+ { :call , 30 , { :remote , 30 , { :atom , 30 , :erlang } , { :atom , 30 , :is_atom } } ,
48+ [ { :atom , 29 , :ok } ] } ,
49+ { :call , 33 , { :remote , 33 , { :atom , 33 , :erlang } , { :atom , 33 , :is_atom } } ,
5050 [
51- { :cons , 22 , { :integer , 22 , 1 } ,
52- { :cons , 22 , { :integer , 22 , 2 } , { :cons , 22 , { :integer , 22 , 3 } , { nil , 22 } } } }
51+ { :cons , 32 , { :integer , 32 , 1 } ,
52+ { :cons , 32 , { :integer , 32 , 2 } , { :cons , 32 , { :integer , 32 , 3 } , { nil , 32 } } } }
5353 ] } ,
54- { :call , 26 , { :remote , 26 , { :atom , 26 , :erlang } , { :atom , 26 , :is_atom } } ,
55- [ { :tuple , 25 , [ { :integer , 25 , 1 } , { :integer , 25 , 2 } , { :integer , 25 , 3 } ] } ] } ,
56- { :call , 29 , { :remote , 29 , { :atom , 29 , :erlang } , { :atom , 29 , :is_atom } } ,
57- [ { :bin , 28 , [ { :bin_element , 28 , { :string , 28 , 'a' } , :default , :default } ] } ] }
54+ { :call , 36 , { :remote , 36 , { :atom , 36 , :erlang } , { :atom , 36 , :is_atom } } ,
55+ [ { :tuple , 35 , [ { :integer , 35 , 1 } , { :integer , 35 , 2 } , { :integer , 35 , 3 } ] } ] } ,
56+ { :call , 39 , { :remote , 39 , { :atom , 39 , :erlang } , { :atom , 39 , :is_atom } } ,
57+ [ { :bin , 38 , [ { :bin_element , 38 , { :string , 38 , 'a' } , :default , :default } ] } ] }
5858 ] } }
5959 end
6060
@@ -69,14 +69,84 @@ defmodule Gradient.AstData do
6969 [ { :integer , 56 , 1 } , { :atom , 55 , :ok } ] } }
7070 end
7171
72+ defp complex_list_pipe do
73+ { __ENV__ . function ,
74+ { __ENV__ . line ,
75+ elixir_to_ast do
76+ [
77+ { 1 , % { a: 1 } } ,
78+ { 2 , % { a: 2 } }
79+ ]
80+ |> Enum . map ( & elem ( & 1 , 0 ) )
81+ end , __ENV__ . line } ,
82+ { :call , 80 , { :remote , 80 , { :atom , 80 , Enum } , { :atom , 80 , :map } } ,
83+ [
84+ { :cons , 76 ,
85+ { :tuple , 77 ,
86+ [
87+ { :integer , 77 , 1 } ,
88+ { :map , 77 , [ { :map_field_assoc , 77 , { :atom , 77 , :a } , { :integer , 77 , 1 } } ] }
89+ ] } ,
90+ { :cons , 77 ,
91+ { :tuple , 78 ,
92+ [
93+ { :integer , 78 , 2 } ,
94+ { :map , 78 , [ { :map_field_assoc , 78 , { :atom , 78 , :a } , { :integer , 78 , 2 } } ] }
95+ ] } , { nil , 77 } } } ,
96+ { :fun , 80 ,
97+ { :clauses ,
98+ [
99+ { :clause , 80 , [ { :var , 0 , :_@1 } ] , [ ] ,
100+ [
101+ { :call , 80 , { :remote , 80 , { :atom , 80 , :erlang } , { :atom , 80 , :element } } ,
102+ [ { :integer , 80 , 1 } , { :var , 0 , :_@1 } ] }
103+ ] }
104+ ] } }
105+ ] } }
106+ end
107+
108+ defp complex_tuple_pipe do
109+ { __ENV__ . function ,
110+ { __ENV__ . line ,
111+ elixir_to_ast do
112+ {
113+ { 1 , % { a: 1 } } ,
114+ { 2 , % { a: 2 } }
115+ }
116+ |> Tuple . to_list ( )
117+ end , __ENV__ . line } ,
118+ { :call , 119 , { :remote , 119 , { :atom , 119 , :erlang } , { :atom , 119 , :tuple_to_list } } ,
119+ [
120+ { :tuple , 115 ,
121+ [
122+ { :tuple , 116 ,
123+ [
124+ { :integer , 116 , 1 } ,
125+ { :map , 116 , [ { :map_field_assoc , 116 , { :atom , 116 , :a } , { :integer , 116 , 1 } } ] }
126+ ] } ,
127+ { :tuple , 117 ,
128+ [
129+ { :integer , 117 , 2 } ,
130+ { :map , 117 , [ { :map_field_assoc , 117 , { :atom , 117 , :a } , { :integer , 117 , 2 } } ] }
131+ ] }
132+ ] }
133+ ] } }
134+ end
135+
72136 @ spec ast_data ( ) :: [
73- { atom ( ) , { Types . abstract_expr ( ) , Types . tokens ( ) , Types . options ( ) } , tuple ( ) }
137+ { atom ( ) , { Types . abstract_expr ( ) , Types . tokens ( ) , Types . options ( ) } ,
138+ Types . abstract_expr ( ) }
74139 ]
75140 def ast_data do
76- [ pipe ( ) , pipe_with_fun_converted_to_erl_equivalent ( ) ]
141+ [
142+ pipe ( ) ,
143+ pipe_with_fun_converted_to_erl_equivalent ( ) ,
144+ complex_list_pipe ( ) ,
145+ complex_tuple_pipe ( )
146+ ]
77147 |> Enum . map ( fn { { name , _ } , { start_line , ast , end_line } , expected } ->
78- tokens = Gradient.Tokens . drop_tokens_to_line ( @ tokens , start_line )
79- { name , { ast , tokens , [ line: start_line , end_line: end_line ] } , expected }
148+ tokens = Gradient.Tokens . drop_tokens_to_line ( @ tokens , start_line + 1 )
149+ { name , { ast , tokens , [ line: start_line + 1 , end_line: end_line ] } , expected }
80150 end )
81151 end
82152
0 commit comments