Skip to content

Commit e5f158b

Browse files
committed
fix warnings
1 parent cf3c16c commit e5f158b

File tree

5 files changed

+23
-26
lines changed

5 files changed

+23
-26
lines changed

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: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ defmodule ElixirLS.LanguageServer.Providers.CodeAction.Helpers do
55
@spec update_line(GenLSP.Structures.TextEdit.t(), non_neg_integer()) ::
66
GenLSP.Structures.TextEdit.t()
77
def update_line(
8-
%GenLSP.Structures.TextEdit{range: range} = text_edit,
8+
%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: %GenLSP.Structures.Range{
14-
range
15-
| start: %GenLSP.Structures.Position{range.start | line: line_number},
16-
end: %GenLSP.Structures.Position{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: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -592,11 +592,11 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
592592
&("alias " <> &1)
593593
)
594594

595+
%CompletionItem{} = completion_item = completion_without_additional_text_edit.completion_item
596+
595597
%__MODULE__{
596598
priority: 24,
597-
completion_item: %CompletionItem{
598-
completion_without_additional_text_edit.completion_item
599-
| additional_text_edit: %GenLSP.Structures.TextEdit{
599+
completion_item: %{completion_item | additional_text_edit: %GenLSP.Structures.TextEdit{
600600
range: %GenLSP.Structures.Range{
601601
start: %GenLSP.Structures.Position{line: line_to_insert_alias, character: 0},
602602
end: %GenLSP.Structures.Position{line: line_to_insert_alias, character: 0}
@@ -1023,9 +1023,10 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
10231023
if completion do
10241024
completion =
10251025
if name in @operators do
1026+
%CompletionItem{} = completion_item = completion.completion_item
10261027
%__MODULE__{
10271028
completion
1028-
| completion_item: %CompletionItem{completion.completion_item | kind: :operator}
1029+
| completion_item: %{completion_item | kind: :operator}
10291030
}
10301031
else
10311032
completion
@@ -1049,11 +1050,10 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
10491050
&("require " <> &1)
10501051
)
10511052

1053+
%CompletionItem{} = completion_item = completion.completion_item
10521054
%__MODULE__{
10531055
completion
1054-
| completion_item: %CompletionItem{
1055-
completion.completion_item
1056-
| additional_text_edit: %GenLSP.Structures.TextEdit{
1056+
| completion_item: %{completion_item | additional_text_edit: %GenLSP.Structures.TextEdit{
10571057
range: %GenLSP.Structures.Range{
10581058
start: %GenLSP.Structures.Position{
10591059
line: line_to_insert_require,
@@ -1073,13 +1073,10 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
10731073
file_path = Keyword.get(options, :file_path)
10741074

10751075
if snippet = snippet_for({origin, name}, Map.put(context, :file_path, file_path)) do
1076+
%CompletionItem{} = completion_item = completion.completion_item
10761077
%__MODULE__{
10771078
completion
1078-
| completion_item: %CompletionItem{
1079-
completion.completion_item
1080-
| insert_text: snippet,
1081-
label: name
1082-
}
1079+
| completion_item: %{completion_item | insert_text: snippet, label: name}
10831080
}
10841081
else
10851082
completion

apps/language_server/lib/language_server/server.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -707,11 +707,11 @@ defmodule ElixirLS.LanguageServer.Server do
707707
state
708708
else
709709
state =
710-
update_in(state.source_files[uri], fn source_file ->
710+
update_in(state.source_files[uri], fn %SourceFile{} = source_file ->
711711
# LSP 3.17: The version number points to the version after all provided content changes have
712712
# been applied
713713
updated_source_file =
714-
%SourceFile{source_file | version: version, dirty?: true}
714+
%{source_file | version: version, dirty?: true}
715715
|> SourceFile.apply_content_changes(content_changes)
716716

717717
Parser.parse_with_debounce(uri, updated_source_file)
@@ -817,7 +817,7 @@ defmodule ElixirLS.LanguageServer.Server do
817817
%SourceFile{text: source_file_text, dirty?: true} = source_file ->
818818
case File.read(SourceFile.Path.from_uri(uri)) do
819819
{:ok, ^source_file_text} ->
820-
Map.put(acc, uri, %SourceFile{source_file | dirty?: false})
820+
Map.put(acc, uri, %{source_file | dirty?: false})
821821

822822
{:ok, _} ->
823823
acc
@@ -2003,7 +2003,7 @@ defmodule ElixirLS.LanguageServer.Server do
20032003
# diagnostics without file are meaningless in LSP, try to point to mixfile instead
20042004
if project_dir != nil and mix_project? do
20052005
file = Path.join(project_dir, MixfileHelpers.mix_exs())
2006-
%Diagnostics{diagnostic | file: file, source: file, position: 0}
2006+
%{diagnostic | file: file, source: file, position: 0}
20072007
end
20082008
end
20092009
end)

0 commit comments

Comments
 (0)