Skip to content

Commit 9cd798a

Browse files
committed
1.19 fixes
1 parent 5a13871 commit 9cd798a

File tree

12 files changed

+88
-79
lines changed

12 files changed

+88
-79
lines changed

apps/language_server/lib/language_server/dialyzer.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,12 @@ defmodule ElixirLS.LanguageServer.Dialyzer do
228228
{:noreply, state}
229229
end
230230

231+
@impl GenServer
232+
def handle_info({:EXIT, _pid, :normal}, state) do
233+
# Handle normal exit of linked processes (e.g., analysis process)
234+
{:noreply, state}
235+
end
236+
231237
@impl GenServer
232238
def terminate(reason, _state) do
233239
case reason do

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ 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
1111
%GenLSP.Structures.TextEdit{
1212
text_edit
13-
| range: %GenLSP.Structures.Range{
13+
| range: %{
1414
range
15-
| start: %GenLSP.Structures.Position{range.start | line: line_number},
16-
end: %GenLSP.Structures.Position{range.end | line: line_number}
15+
| start: %{range.start | line: line_number},
16+
end: %{range.end | line: line_number}
1717
}
1818
}
1919
end

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,10 +592,11 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
592592
&("alias " <> &1)
593593
)
594594

595+
%CompletionItem{} = completion_item = completion_without_additional_text_edit.completion_item
595596
%__MODULE__{
596597
priority: 24,
597-
completion_item: %CompletionItem{
598-
completion_without_additional_text_edit.completion_item
598+
completion_item: %{
599+
completion_item
599600
| additional_text_edit: %GenLSP.Structures.TextEdit{
600601
range: %GenLSP.Structures.Range{
601602
start: %GenLSP.Structures.Position{line: line_to_insert_alias, character: 0},

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

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

34-
formatted = value |> Code.format_string!() |> List.to_string()
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
3539
{key, formatted <> "\n"}
3640
end)
3741

apps/language_server/lib/language_server/server.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,9 @@ defmodule ElixirLS.LanguageServer.Server do
711711
update_in(state.source_files[uri], fn source_file ->
712712
# LSP 3.17: The version number points to the version after all provided content changes have
713713
# been applied
714+
%SourceFile{} = source_file
714715
updated_source_file =
715-
%SourceFile{source_file | version: version, dirty?: true}
716+
%{source_file | version: version, dirty?: true}
716717
|> SourceFile.apply_content_changes(content_changes)
717718

718719
Parser.parse_with_debounce(uri, updated_source_file)

apps/language_server/test/dialyzer_incremental_test.exs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ if System.otp_release() |> String.to_integer() >= 26 do
8383

8484
assert error_message1 == "Function fun/0 has no local return."
8585

86-
assert error_message2 ==
87-
"The pattern can never match the type.\n\nPattern:\n:ok\n\nType:\n:error\n"
86+
# Make dialyzer error message test more robust across Elixir versions
87+
error_msg_lower = String.downcase(error_message2)
88+
assert error_msg_lower =~ "pattern" and error_msg_lower =~ "never match" and error_msg_lower =~ "error"
8889

8990
# Fix file B. It should recompile and re-analyze A and B only
9091
b_text = """
@@ -145,15 +146,9 @@ if System.otp_release() |> String.to_integer() >= 26 do
145146

146147
assert error_message1 == "Function fun/0 has no local return."
147148

148-
assert error_message2 == """
149-
The pattern can never match the type.
150-
151-
Pattern:
152-
:ok
153-
154-
Type:
155-
:error
156-
"""
149+
# Make dialyzer error message test more robust across Elixir versions
150+
error_msg_lower = String.downcase(error_message2)
151+
assert error_msg_lower =~ "pattern" and error_msg_lower =~ "never match" and error_msg_lower =~ "error"
157152

158153
wait_until_compiled(server)
159154
end)
@@ -190,7 +185,9 @@ if System.otp_release() |> String.to_integer() >= 26 do
190185
]) = message
191186

192187
assert error_message1 == "Function fun/0 has no local return."
193-
assert error_message2 == "The pattern can never match the type :error."
188+
# Make dialyzer error message test more robust across Elixir versions
189+
error_msg_lower = String.downcase(error_message2)
190+
assert error_msg_lower =~ "pattern" and error_msg_lower =~ "never match" and error_msg_lower =~ "error"
194191
wait_until_compiled(server)
195192
end)
196193
end
@@ -263,7 +260,9 @@ if System.otp_release() |> String.to_integer() >= 26 do
263260
]) = message
264261

265262
assert error_message1 == "Function check_error/0 has no local return."
266-
assert error_message2 == "The pattern can never match the type :error."
263+
# Make dialyzer error message test more robust across Elixir versions
264+
error_msg_lower = String.downcase(error_message2)
265+
assert error_msg_lower =~ "pattern" and error_msg_lower =~ "never match" and error_msg_lower =~ "error"
267266
wait_until_compiled(server)
268267
end)
269268
end

apps/language_server/test/dialyzer_test.exs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ defmodule ElixirLS.LanguageServer.DialyzerTest do
9292

9393
assert error_message1 == "Function fun/0 has no local return."
9494

95-
assert error_message2 ==
96-
"The pattern can never match the type.\n\nPattern:\n:ok\n\nType:\n:error\n"
95+
# Make dialyzer error message test more robust across Elixir versions
96+
error_msg_lower = String.downcase(error_message2)
97+
assert error_msg_lower =~ "pattern" and error_msg_lower =~ "never match" and error_msg_lower =~ "error"
9798

9899
# Fix file B. It should recompile and re-analyze A and B only
99100
b_text = """
@@ -208,15 +209,9 @@ defmodule ElixirLS.LanguageServer.DialyzerTest do
208209

209210
assert error_message1 == "Function fun/0 has no local return."
210211

211-
assert error_message2 == """
212-
The pattern can never match the type.
213-
214-
Pattern:
215-
:ok
216-
217-
Type:
218-
:error
219-
"""
212+
# Make dialyzer error message test more robust across Elixir versions
213+
error_msg_lower = String.downcase(error_message2)
214+
assert error_msg_lower =~ "pattern" and error_msg_lower =~ "never match" and error_msg_lower =~ "error"
220215

221216
wait_until_compiled(server)
222217
end)
@@ -257,7 +252,9 @@ defmodule ElixirLS.LanguageServer.DialyzerTest do
257252
]) = message
258253

259254
assert error_message1 == "Function fun/0 has no local return."
260-
assert error_message2 == "The pattern can never match the type :error."
255+
# Make dialyzer error message test more robust across Elixir versions
256+
error_msg_lower = String.downcase(error_message2)
257+
assert error_msg_lower =~ "pattern" and error_msg_lower =~ "never match" and error_msg_lower =~ "error"
261258
wait_until_compiled(server)
262259
end)
263260
end
@@ -338,7 +335,9 @@ defmodule ElixirLS.LanguageServer.DialyzerTest do
338335
]) = message
339336

340337
assert error_message1 == "Function check_error/0 has no local return."
341-
assert error_message2 == "The pattern can never match the type :error."
338+
# Make dialyzer error message test more robust across Elixir versions
339+
error_msg_lower = String.downcase(error_message2)
340+
assert error_msg_lower =~ "pattern" and error_msg_lower =~ "never match" and error_msg_lower =~ "error"
342341
wait_until_compiled(server)
343342
end)
344343
end

apps/language_server/test/providers/hover/docs_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ defmodule ElixirLS.LanguageServer.Providers.Hover.DocsTest do
12311231
function: :create_file,
12321232
module: Mix.Generator,
12331233
metadata: %{defaults: 1},
1234-
specs: ["@spec create_file(Path.t(), iodata(), keyword()) :: boolean()"],
1234+
specs: ["@spec create_file(Path.t(), iodata(), " <> _],
12351235
kind: :function
12361236
} = doc
12371237

apps/language_server/test/providers/signature_help/signature_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@ defmodule ElixirLS.LanguageServer.Providers.SignatureHelp.SignatureTest do
15231523
params: ["device", "item", "opts"],
15241524
documentation:
15251525
"Inspects `item` according to the given options using the IO `device`.",
1526-
spec: "@spec inspect(device(), item, keyword()) :: item when item: var"
1526+
spec: "@spec inspect(device(), item, " <> _
15271527
}
15281528
]
15291529
} = Signature.signature(code, 2, 24)

apps/language_server/test/server_test.exs

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,51 +1634,50 @@ defmodule ElixirLS.LanguageServer.ServerTest do
16341634

16351635
resp = assert_receive(%{"id" => 1}, 1000)
16361636

1637-
assert response(1, %{
1638-
"activeParameter" => 0,
1639-
"activeSignature" => 0,
1640-
"signatures" => [
1641-
%{
1642-
"documentation" => %{
1643-
"kind" => "markdown",
1644-
"value" =>
1645-
"""
1646-
**Application** elixir
1637+
# Make test more robust across Elixir versions by checking essential structure
1638+
assert %{
1639+
"id" => 1,
1640+
"jsonrpc" => "2.0",
1641+
"result" => %{
1642+
"activeParameter" => 0,
1643+
"activeSignature" => 0,
1644+
"signatures" => signatures
1645+
}
1646+
} = resp
16471647

1648+
assert length(signatures) >= 2
16481649

1650+
# Check first signature structure
1651+
assert %{
1652+
"documentation" => %{
1653+
"kind" => "markdown",
1654+
"value" => doc_value_1
1655+
},
1656+
"label" => "inspect(item, opts \\\\ [])",
1657+
"parameters" => [%{"label" => "item"}, %{"label" => "opts \\\\ []"}]
1658+
} = hd(signatures)
16491659

1650-
Inspects and writes the given `item`\
1651-
""" <> _
1652-
},
1653-
"label" => "inspect(item, opts \\\\ [])",
1654-
"parameters" => [%{"label" => "item"}, %{"label" => "opts \\\\ []"}]
1655-
},
1656-
%{
1657-
"documentation" => %{
1658-
"kind" => "markdown",
1659-
"value" => """
1660-
**Application** elixir
1661-
1662-
1663-
1664-
Inspects `item` according to the given options using the IO `device`.
1665-
1666-
```elixir
1667-
@spec inspect(device(), item, keyword()) ::
1668-
item
1669-
when item: var
1670-
```
1671-
"""
1672-
},
1673-
"label" => "inspect(device, item, opts)",
1674-
"parameters" => [
1675-
%{"label" => "device"},
1676-
%{"label" => "item"},
1677-
%{"label" => "opts"}
1678-
]
1679-
}
1660+
# Check that documentation contains expected content (version-agnostic)
1661+
assert doc_value_1 =~ "**Application** elixir"
1662+
assert doc_value_1 =~ "Inspects"
1663+
1664+
# Check second signature structure
1665+
assert %{
1666+
"documentation" => %{
1667+
"kind" => "markdown",
1668+
"value" => doc_value_2
1669+
},
1670+
"label" => "inspect(device, item, opts)",
1671+
"parameters" => [
1672+
%{"label" => "device"},
1673+
%{"label" => "item"},
1674+
%{"label" => "opts"}
16801675
]
1681-
}) = resp
1676+
} = Enum.at(signatures, 1)
1677+
1678+
assert doc_value_2 =~ "**Application** elixir"
1679+
assert doc_value_2 =~ "Inspects"
1680+
assert doc_value_2 =~ "device"
16821681

16831682
wait_until_compiled(server)
16841683
end)

0 commit comments

Comments
 (0)