Skip to content

Commit f385ec2

Browse files
committed
format
1 parent 4c97baa commit f385ec2

File tree

5 files changed

+43
-59
lines changed

5 files changed

+43
-59
lines changed

lib/elixir_sense/core/compiler/map.ex

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,28 @@ defmodule ElixirSense.Core.Compiler.Map do
1010
case validate_struct(e_left, context) do
1111
true when is_atom(e_left) ->
1212
case e_right do
13-
{:"%{}", _map_meta, [{:|, _, [_, assocs]}]} ->
13+
{:%{}, _map_meta, [{:|, _, [_, assocs]}]} ->
1414
assocs = sanitize_assocs(assocs)
1515
# elixir warns about deprecated struct update
1616
:elixir_env.trace({:struct_expansion, meta, e_left, assocs}, e)
17-
{{:"%", meta, [e_left, e_right]}, se, ee}
18-
{:"%{}", map_meta, assocs} when context != :match ->
17+
{{:%, meta, [e_left, e_right]}, se, ee}
18+
19+
{:%{}, map_meta, assocs} when context != :match ->
1920
assocs = sanitize_assocs(assocs)
2021
assoc_keys = Enum.map(assocs, fn {k, _} -> k end)
2122
struct = load_struct(meta, e_left, [assocs], se, ee)
2223
keys = [:__struct__ | assoc_keys]
23-
without_keys = Elixir.Map.drop(struct, keys)
24-
|> Elixir.Map.to_list
25-
|> Enum.sort
24+
25+
without_keys =
26+
Elixir.Map.drop(struct, keys)
27+
|> Elixir.Map.to_list()
28+
|> Enum.sort()
2629

2730
{struct_assocs, se} = Compiler.Quote.escape(without_keys, :escape, false, se)
2831

2932
{{:%, meta, [e_left, {:%{}, map_meta, struct_assocs ++ assocs}]}, se, ee}
3033

31-
{:"%{}", _map_meta, assocs} ->
34+
{:%{}, _map_meta, assocs} ->
3235
assocs = sanitize_assocs(assocs)
3336
:elixir_env.trace({:struct_expansion, meta, e_left, assocs}, e)
3437
# elixir validates assocs against struct keys

lib/elixir_sense/core/compiler/quote.ex

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,16 @@ defmodule ElixirSense.Core.Compiler.Quote do
130130

131131
def escape(expr, op, unquote, state) do
132132
try do
133-
do_quote(expr, %__MODULE__{
134-
line: true,
135-
file: nil,
136-
op: op,
137-
unquote: unquote
138-
}, state)
133+
do_quote(
134+
expr,
135+
%__MODULE__{
136+
line: true,
137+
file: nil,
138+
op: op,
139+
unquote: unquote
140+
},
141+
state
142+
)
139143
catch
140144
_kind, _reason ->
141145
# elixir reraises here with trimmed stacktrace
@@ -370,8 +374,7 @@ defmodule ElixirSense.Core.Compiler.Quote do
370374

371375
# elixir does not emit remote_function in quoted as AST is meaningless
372376
{quoted_meta, state} = meta(meta, q, state)
373-
{{{:., meta, [:elixir_quote, :dot]}, meta, [quoted_meta | Enum.reverse(tall_reverse)]},
374-
state}
377+
{{{:., meta, [:elixir_quote, :dot]}, meta, [quoted_meta | Enum.reverse(tall_reverse)]}, state}
375378
end
376379

377380
defp do_quote_tuple({left, meta, right}, q, state) do

test/elixir_sense/core/binding_test.exs

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ defmodule ElixirSense.Core.BindingTest do
9898
__struct__: {:atom, ElixirSenseExample.ModuleWithTypedStruct},
9999
other: nil,
100100
typed_field: nil
101-
], {:atom, ElixirSenseExample.ModuleWithTypedStruct},
102-
nil} ==
101+
], {:atom, ElixirSenseExample.ModuleWithTypedStruct}, nil} ==
103102
Binding.expand(
104103
@env,
105104
{:struct, [], {:atom, ElixirSenseExample.ModuleWithTypedStruct}, nil}
@@ -205,8 +204,7 @@ defmodule ElixirSense.Core.BindingTest do
205204
__struct__: {:atom, ElixirSenseExample.ModuleWithTypedStruct},
206205
other: {:atom, :a},
207206
typed_field: {:atom, :b}
208-
], {:atom, ElixirSenseExample.ModuleWithTypedStruct},
209-
nil} ==
207+
], {:atom, ElixirSenseExample.ModuleWithTypedStruct}, nil} ==
210208
Binding.expand(
211209
@env,
212210
{:struct, [typed_field: {:atom, :b}],
@@ -222,8 +220,7 @@ defmodule ElixirSense.Core.BindingTest do
222220
__struct__: {:atom, ElixirSenseExample.ModuleWithTypedStruct},
223221
other: {:atom, :a},
224222
typed_field: {:atom, :b}
225-
], {:atom, ElixirSenseExample.ModuleWithTypedStruct},
226-
nil} ==
223+
], {:atom, ElixirSenseExample.ModuleWithTypedStruct}, nil} ==
227224
Binding.expand(
228225
@env,
229226
{:map, [typed_field: {:atom, :b}],
@@ -238,8 +235,7 @@ defmodule ElixirSense.Core.BindingTest do
238235
__struct__: {:atom, ElixirSenseExample.ModuleWithTypedStruct},
239236
other: nil,
240237
typed_field: nil
241-
], {:atom, ElixirSenseExample.ModuleWithTypedStruct},
242-
nil} ==
238+
], {:atom, ElixirSenseExample.ModuleWithTypedStruct}, nil} ==
243239
Binding.expand(
244240
@env
245241
|> Map.put(:attributes, [
@@ -1044,8 +1040,7 @@ defmodule ElixirSense.Core.BindingTest do
10441040
[
10451041
__struct__: {:atom, ElixirSenseExample.FunctionsWithReturnSpec},
10461042
abc: {:map, [key: {:atom, nil}], nil}
1047-
], {:atom, ElixirSenseExample.FunctionsWithReturnSpec},
1048-
nil} ==
1043+
], {:atom, ElixirSenseExample.FunctionsWithReturnSpec}, nil} ==
10491044
Binding.expand(
10501045
@env
10511046
|> Map.put(:vars, [
@@ -1062,8 +1057,7 @@ defmodule ElixirSense.Core.BindingTest do
10621057
test "remote call fun with spec remote t expanding to struct" do
10631058
assert {:struct,
10641059
[__struct__: {:atom, ElixirSenseExample.FunctionsWithReturnSpec.Remote}, abc: nil],
1065-
{:atom, ElixirSenseExample.FunctionsWithReturnSpec.Remote},
1066-
nil} ==
1060+
{:atom, ElixirSenseExample.FunctionsWithReturnSpec.Remote}, nil} ==
10671061
Binding.expand(
10681062
@env
10691063
|> Map.put(:vars, [
@@ -1080,8 +1074,7 @@ defmodule ElixirSense.Core.BindingTest do
10801074
test "remote call fun with spec struct" do
10811075
assert {:struct,
10821076
[__struct__: {:atom, ElixirSenseExample.FunctionsWithReturnSpec}, abc: nil],
1083-
{:atom, ElixirSenseExample.FunctionsWithReturnSpec},
1084-
nil} ==
1077+
{:atom, ElixirSenseExample.FunctionsWithReturnSpec}, nil} ==
10851078
Binding.expand(
10861079
@env
10871080
|> Map.put(:vars, [
@@ -2606,8 +2599,7 @@ defmodule ElixirSense.Core.BindingTest do
26062599
{:__struct__, {:atom, State}},
26072600
{:abc, nil},
26082601
{:formatted, {:variable, :formatted, 1}}
2609-
], {:atom, State},
2610-
nil} ==
2602+
], {:atom, State}, nil} ==
26112603
Binding.expand(
26122604
@env
26132605
|> Map.merge(%{
@@ -2708,8 +2700,7 @@ defmodule ElixirSense.Core.BindingTest do
27082700
{:__struct__, {:atom, State}},
27092701
{:abc, {:atom, X}},
27102702
{:formatted, {:variable, :formatted, 1}}
2711-
], {:atom, State},
2712-
nil} ==
2703+
], {:atom, State}, nil} ==
27132704
Binding.expand(
27142705
@env
27152706
|> Map.merge(%{
@@ -2731,8 +2722,7 @@ defmodule ElixirSense.Core.BindingTest do
27312722
{:__struct__, {:atom, State}},
27322723
{:abc, {:atom, X}},
27332724
{:formatted, {:variable, :formatted, 1}}
2734-
], {:atom, State},
2735-
nil} ==
2725+
], {:atom, State}, nil} ==
27362726
Binding.expand(
27372727
@env
27382728
|> Map.merge(%{
@@ -2757,8 +2747,7 @@ defmodule ElixirSense.Core.BindingTest do
27572747
{:formatted, {:variable, :formatted, 1}},
27582748
{:not_existing, nil},
27592749
{:abc, {:atom, X}}
2760-
], nil,
2761-
nil} ==
2750+
], nil, nil} ==
27622751
Binding.expand(
27632752
@env,
27642753
{:intersection,
@@ -2776,8 +2765,7 @@ defmodule ElixirSense.Core.BindingTest do
27762765
{:formatted, {:variable, :formatted, 1}},
27772766
{:not_existing, nil},
27782767
{:abc, {:atom, X}}
2779-
], nil,
2780-
nil} ==
2768+
], nil, nil} ==
27812769
Binding.expand(
27822770
@env,
27832771
{:intersection,
@@ -2794,8 +2782,7 @@ defmodule ElixirSense.Core.BindingTest do
27942782
{:__struct__, {:atom, State}},
27952783
{:abc, {:atom, X}},
27962784
{:formatted, {:variable, :formatted, 1}}
2797-
], {:atom, State},
2798-
nil} ==
2785+
], {:atom, State}, nil} ==
27992786
Binding.expand(
28002787
@env
28012788
|> Map.merge(%{
@@ -2817,8 +2804,7 @@ defmodule ElixirSense.Core.BindingTest do
28172804
{:__struct__, {:atom, State}},
28182805
{:abc, {:atom, X}},
28192806
{:formatted, {:variable, :formatted, 1}}
2820-
], {:atom, State},
2821-
nil} ==
2807+
], {:atom, State}, nil} ==
28222808
Binding.expand(
28232809
@env
28242810
|> Map.merge(%{
@@ -2842,8 +2828,7 @@ defmodule ElixirSense.Core.BindingTest do
28422828
{:__struct__, {:atom, State}},
28432829
{:abc, {:atom, X}},
28442830
{:formatted, {:variable, :formatted, 1}}
2845-
], {:atom, State},
2846-
nil} ==
2831+
], {:atom, State}, nil} ==
28472832
Binding.expand(
28482833
@env
28492834
|> Map.merge(%{

test/elixir_sense/core/compiler/typespec_test.exs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,7 @@ defmodule ElixirSense.Core.Compiler.TypespecTest do
205205
:"::",
206206
[],
207207
[{:some, [], nil}, {:"::", [], [{:other, [], nil}, {:any, [], []}]}]
208-
},
209-
_state} =
208+
}, _state} =
210209
expand_typespec(
211210
{:"::", [],
212211
[{:some, [], nil}, {:"::", [], [{:other, [], nil}, {:any, [], nil}]}]}
@@ -226,8 +225,7 @@ defmodule ElixirSense.Core.Compiler.TypespecTest do
226225
:|,
227226
[],
228227
[{:some, [], []}, {:|, [], [{:other, [], []}, {:any, [], []}]}]
229-
},
230-
_state} =
228+
}, _state} =
231229
expand_typespec(
232230
{:|, [], [{:some, [], nil}, {:|, [], [{:other, [], nil}, {:any, [], nil}]}]}
233231
)
@@ -280,8 +278,7 @@ defmodule ElixirSense.Core.Compiler.TypespecTest do
280278
year: {:term, [], []}
281279
]}
282280
]
283-
},
284-
_state} =
281+
}, _state} =
285282
expand_typespec({:%, [], [{:__aliases__, [], [:Date]}, {:%{}, [], [day: :foo]}]})
286283

287284
# non atom key
@@ -298,8 +295,7 @@ defmodule ElixirSense.Core.Compiler.TypespecTest do
298295
year: {:term, [], []}
299296
]}
300297
]
301-
},
302-
_state} =
298+
}, _state} =
303299
expand_typespec({:%, [], [{:__aliases__, [], [:Date]}, {:%{}, [], [{"day", :foo}]}]})
304300

305301
# invalid key
@@ -316,8 +312,7 @@ defmodule ElixirSense.Core.Compiler.TypespecTest do
316312
year: {:term, [], []}
317313
]}
318314
]
319-
},
320-
_state} =
315+
}, _state} =
321316
expand_typespec({:%, [], [{:__aliases__, [], [:Date]}, {:%{}, [], [{:baz, :foo}]}]})
322317

323318
# non atom

test/elixir_sense/core/parser_test.exs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,7 @@ defmodule ElixirSense.Core.ParserTest do
273273
calls: %{
274274
2 => [%CallInfo{func: :inspect}, %CallInfo{mod: IO}]
275275
}
276-
},
277-
%Env{module: MyModule}} =
276+
}, %Env{module: MyModule}} =
278277
parse(source, {5, 10})
279278
end
280279

@@ -294,8 +293,7 @@ defmodule ElixirSense.Core.ParserTest do
294293
calls: %{
295294
2 => [%CallInfo{func: :inspect}, %CallInfo{mod: IO}]
296295
}
297-
},
298-
%Env{module: MyModule}} =
296+
}, %Env{module: MyModule}} =
299297
parse(source, {5, 12})
300298
end
301299

0 commit comments

Comments
 (0)