Skip to content

Commit 0b8df82

Browse files
committed
Merge branch '1.19'
# Conflicts: # apps/language_server/lib/language_server/providers/code_action/helpers.ex # apps/language_server/lib/language_server/providers/completion.ex # apps/language_server/lib/language_server/providers/execute_command/expand_macro.ex
2 parents 9cd798a + 2b43483 commit 0b8df82

File tree

11 files changed

+27
-37
lines changed

11 files changed

+27
-37
lines changed

apps/debug_adapter/lib/debug_adapter/server.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3272,10 +3272,10 @@ defmodule ElixirLS.DebugAdapter.Server do
32723272
vars =
32733273
for var_name <- Enum.uniq(env_var_names ++ binding_var_names) do
32743274
case {Keyword.fetch(binding, var_name), Map.fetch(env_vars, var_name)} do
3275-
{{:ok, binding_value}, {:ok, env_var}} ->
3275+
{{:ok, binding_value}, {:ok, env_var = %ElixirSense.Core.State.VarInfo{}}} ->
32763276
# var both in env and in binding - prefer type from binding
32773277
type = ElixirSense.Core.Binding.from_var(binding_value)
3278-
%ElixirSense.Core.State.VarInfo{env_var | type: type}
3278+
%{env_var | type: type}
32793279

32803280
{_, {:ok, env_var}} ->
32813281
# var only in env - keep it, binding may not have everything

apps/debug_adapter/test/debugger_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3569,7 +3569,7 @@ defmodule ElixirLS.DebugAdapter.ServerTest do
35693569
1,
35703570
"evaluate",
35713571
"evaluateError",
3572-
"** (MatchError) no match of right hand side value: 2" <> _,
3572+
"** (MatchError) no match of right hand side value:" <> _,
35733573
%{},
35743574
_,
35753575
_

apps/language_server/lib/language_server/parser.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ defmodule ElixirLS.LanguageServer.Parser do
148148
%Context{source_file: %SourceFile{version: old_version}} = old_file
149149
when current_version > old_version ->
150150
# replace updated file with new version
151-
%Context{old_file | source_file: source_file}
151+
%{old_file | source_file: source_file}
152152

153153
%Context{} = old_file ->
154154
# ignore this request - this or newer version already in state
@@ -192,7 +192,7 @@ defmodule ElixirLS.LanguageServer.Parser do
192192

193193
%Context{source_file: %SourceFile{version: old_version}} = old_file
194194
when old_version <= current_version ->
195-
%Context{old_file | source_file: source_file}
195+
%{old_file | source_file: source_file}
196196
end
197197

198198
{pid, ref} =

apps/language_server/lib/language_server/providers/code_action/helpers.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ defmodule ElixirLS.LanguageServer.Providers.CodeAction.Helpers do
88
%GenLSP.Structures.TextEdit{range: %GenLSP.Structures.Range{} = range} = text_edit,
99
line_number
1010
) do
11-
%GenLSP.Structures.TextEdit{
11+
%GenLSP.Structures.Position{} = start_pos = range.start
12+
%GenLSP.Structures.Position{} = end_pos = range.end
13+
14+
%{
1215
text_edit
13-
| range: %{
14-
range
15-
| start: %{range.start | line: line_number},
16-
end: %{range.end | line: line_number}
17-
}
16+
| range: %{range | start: %{start_pos | line: line_number},
17+
end: %{end_pos | line: line_number}}
1818
}
1919
end
2020

apps/language_server/lib/language_server/providers/code_mod/diff.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ defmodule ElixirLS.LanguageServer.Providers.CodeMod.Diff do
4343
]
4444
)
4545
when byte_size(insert_text) > 0 do
46-
collapsed_edit = %TextEdit{delete_edit | new_text: insert_text}
46+
collapsed_edit = %{delete_edit | new_text: insert_text}
4747
[collapsed_edit | rest]
4848
end
4949

apps/language_server/lib/language_server/providers/completion.ex

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,10 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
593593
)
594594

595595
%CompletionItem{} = completion_item = completion_without_additional_text_edit.completion_item
596+
596597
%__MODULE__{
597598
priority: 24,
598-
completion_item: %{
599-
completion_item
600-
| additional_text_edit: %GenLSP.Structures.TextEdit{
599+
completion_item: %{completion_item | additional_text_edit: %GenLSP.Structures.TextEdit{
601600
range: %GenLSP.Structures.Range{
602601
start: %GenLSP.Structures.Position{line: line_to_insert_alias, character: 0},
603602
end: %GenLSP.Structures.Position{line: line_to_insert_alias, character: 0}
@@ -1024,9 +1023,10 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
10241023
if completion do
10251024
completion =
10261025
if name in @operators do
1026+
%CompletionItem{} = completion_item = completion.completion_item
10271027
%__MODULE__{
10281028
completion
1029-
| completion_item: %CompletionItem{completion.completion_item | kind: :operator}
1029+
| completion_item: %{completion_item | kind: :operator}
10301030
}
10311031
else
10321032
completion
@@ -1050,11 +1050,10 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
10501050
&("require " <> &1)
10511051
)
10521052

1053+
%CompletionItem{} = completion_item = completion.completion_item
10531054
%__MODULE__{
10541055
completion
1055-
| completion_item: %CompletionItem{
1056-
completion.completion_item
1057-
| additional_text_edit: %GenLSP.Structures.TextEdit{
1056+
| completion_item: %{completion_item | additional_text_edit: %GenLSP.Structures.TextEdit{
10581057
range: %GenLSP.Structures.Range{
10591058
start: %GenLSP.Structures.Position{
10601059
line: line_to_insert_require,
@@ -1074,13 +1073,10 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
10741073
file_path = Keyword.get(options, :file_path)
10751074

10761075
if snippet = snippet_for({origin, name}, Map.put(context, :file_path, file_path)) do
1076+
%CompletionItem{} = completion_item = completion.completion_item
10771077
%__MODULE__{
10781078
completion
1079-
| completion_item: %CompletionItem{
1080-
completion.completion_item
1081-
| insert_text: snippet,
1082-
label: name
1083-
}
1079+
| completion_item: %{completion_item | insert_text: snippet, label: name}
10841080
}
10851081
else
10861082
completion

apps/language_server/lib/language_server/providers/execute_command/expand_macro.ex

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.ExpandMacro do
3131
|> Macro.camelize()
3232
|> String.replace("Expand", "expand")
3333

34-
formatted =
35-
case Code.format_string!(value) do
36-
list when is_list(list) -> List.to_string(list)
37-
string when is_binary(string) -> string
38-
end
34+
formatted = value |> Code.format_string!() |> IO.iodata_to_binary()
3935
{key, formatted <> "\n"}
4036
end)
4137

apps/language_server/lib/language_server/providers/hover.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ defmodule ElixirLS.LanguageServer.Providers.Hover do
280280
defp format_header(text) do
281281
text
282282
|> Code.format_string!(line_length: 40)
283-
|> to_string
283+
|> IO.iodata_to_binary()
284284
rescue
285285
_ ->
286286
# Code.format_string! can raise SyntaxError e.g.

apps/language_server/lib/language_server/server.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ defmodule ElixirLS.LanguageServer.Server do
708708
state
709709
else
710710
state =
711-
update_in(state.source_files[uri], fn source_file ->
711+
update_in(state.source_files[uri], fn %SourceFile{} = source_file ->
712712
# LSP 3.17: The version number points to the version after all provided content changes have
713713
# been applied
714714
%SourceFile{} = source_file
@@ -819,7 +819,7 @@ defmodule ElixirLS.LanguageServer.Server do
819819
%SourceFile{text: source_file_text, dirty?: true} = source_file ->
820820
case File.read(SourceFile.Path.from_uri(uri)) do
821821
{:ok, ^source_file_text} ->
822-
Map.put(acc, uri, %SourceFile{source_file | dirty?: false})
822+
Map.put(acc, uri, %{source_file | dirty?: false})
823823

824824
{:ok, _} ->
825825
acc
@@ -2139,7 +2139,7 @@ defmodule ElixirLS.LanguageServer.Server do
21392139
# diagnostics without file are meaningless in LSP, try to point to mixfile instead
21402140
if project_dir != nil and mix_project? do
21412141
file = Path.join(project_dir, MixfileHelpers.mix_exs())
2142-
%Diagnostics{diagnostic | file: file, source: file, position: 0}
2142+
%{diagnostic | file: file, source: file, position: 0}
21432143
end
21442144
end
21452145
end)

apps/language_server/lib/language_server/source_file.ex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ defmodule ElixirLS.LanguageServer.SourceFile do
222222
case format_code(spec, line_length: line_length) do
223223
{:ok, code} ->
224224
code
225-
|> to_string()
226225

227226
{:error, _} ->
228227
spec
@@ -327,7 +326,7 @@ defmodule ElixirLS.LanguageServer.SourceFile do
327326

328327
defp format_code(code, opts) do
329328
try do
330-
{:ok, Code.format_string!(code, opts)}
329+
{:ok, Code.format_string!(code, opts) |> IO.iodata_to_binary()}
331330
rescue
332331
e ->
333332
{:error, e}

0 commit comments

Comments
 (0)