Skip to content

Commit 08fa40c

Browse files
authored
Merge pull request #1147 from elixir-lsp/1.18
1.18
2 parents 9714dd7 + 91a38e6 commit 08fa40c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+735
-309
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ jobs:
6767
- elixir: 1.17.x
6868
otp: 27.x
6969
tests_may_fail: false
70+
# https://github.com/erlef/setup-beam/issues/314
71+
# - elixir: 1.18.x
72+
# otp: 25.x
73+
# tests_may_fail: false
74+
- elixir: 1.18.x
75+
otp: 26.x
76+
tests_may_fail: false
77+
- elixir: 1.18.x
78+
otp: 27.x
79+
tests_may_fail: false
7080
env:
7181
MIX_ENV: test
7282
steps:
@@ -80,7 +90,8 @@ jobs:
8090
mix local.hex --force
8191
mix local.rebar --force
8292
mix deps.get --only test
83-
- run: mix test || ${{ matrix.tests_may_fail }}
93+
- run: mix test
94+
continue-on-error: ${{ matrix.tests_may_fail }}
8495

8596
mix_test_windows:
8697
name: mix test windows (Elixir ${{matrix.elixir}} | Erlang/OTP ${{matrix.otp}})
@@ -126,6 +137,16 @@ jobs:
126137
- elixir: 1.17.x
127138
otp: 27.x
128139
tests_may_fail: false
140+
# https://github.com/erlef/setup-beam/issues/314
141+
# - elixir: 1.18.x
142+
# otp: 25.x
143+
# tests_may_fail: false
144+
- elixir: 1.18.x
145+
otp: 26.x
146+
tests_may_fail: false
147+
- elixir: 1.18.x
148+
otp: 27.x
149+
tests_may_fail: false
129150
env:
130151
MIX_ENV: test
131152
steps:
@@ -143,14 +164,15 @@ jobs:
143164
mix local.rebar --force
144165
mix deps.get --only test
145166
- run: mix test
167+
continue-on-error: ${{ matrix.tests_may_fail }}
146168

147169
static_analysis:
148170
name: static analysis (Elixir ${{matrix.elixir}} | Erlang/OTP ${{matrix.otp}})
149171
runs-on: ubuntu-22.04
150172
strategy:
151173
matrix:
152174
include:
153-
- elixir: 1.17.x
175+
- elixir: 1.18.x
154176
otp: 27.x
155177
steps:
156178
- uses: actions/checkout@v4

.github/workflows/release-asset.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
- name: Set up BEAM
4343
uses: erlef/setup-beam@v1
4444
with:
45-
elixir-version: 1.17.x
45+
elixir-version: 1.18.x
4646
otp-version: 27.x
4747

4848
- name: Install dependencies

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ ElixirLS generally aims to support all supported versions of Elixir on all compa
120120
| 22 | 1.13 | Yes | Erlang docs not working (requires EIP 48) |
121121
| 23 | 1.13 - 1.14 | Yes | None |
122122
| 24 | 1.13 - 1.16 | Yes | None |
123-
| 25 | 1.13.4 - 1.17 | Yes | None |
123+
| 25 | 1.13.4 - 1.18 | Yes | None |
124124
| 26.0.0 - 26.0.1 | any | No | [#886](https://github.com/elixir-lsp/elixir-ls/issues/886) |
125-
| 26.0.2 - 26.1.2 | 1.14.5 - 1.17 | *nix only | [#927](https://github.com/elixir-lsp/elixir-ls/issues/927), [#1023](https://github.com/elixir-lsp/elixir-ls/issues/1023) |
126-
| >= 26.2.0 | 1.14.5 - 1.17 | Yes | None |
125+
| 26.0.2 - 26.1.2 | 1.14.5 - 1.18 | *nix only | [#927](https://github.com/elixir-lsp/elixir-ls/issues/927), [#1023](https://github.com/elixir-lsp/elixir-ls/issues/1023) |
126+
| >= 26.2.0 | 1.14.5 - 1.18 | Yes | None |
127127
| any | 1.15.5 | Yes | Broken formatter [#975](https://github.com/elixir-lsp/elixir-ls/issues/975) |
128-
| 27 | 1.17 | Yes | None |
128+
| 27 | 1.17 - 1.18 | Yes | None |
129129

130130
### Version management
131131

apps/debug_adapter/lib/debug_adapter/server.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@ defmodule ElixirLS.DebugAdapter.Server do
11871187
{state, frame_ids} = ensure_frame_ids(state, pid, stack_frames)
11881188

11891189
stack_frames_json =
1190-
for {%Frame{} = stack_frame, frame_id} <- List.zip([stack_frames, frame_ids]) do
1190+
for {%Frame{} = stack_frame, frame_id} <- Enum.zip([stack_frames, frame_ids]) do
11911191
%{
11921192
"id" => frame_id,
11931193
"name" => Stacktrace.Frame.name(stack_frame),

apps/debug_adapter/lib/debug_adapter/stacktrace.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ defmodule ElixirLS.DebugAdapter.Stacktrace do
6565
[]
6666

6767
_ ->
68-
frames = List.zip([backtrace_rest, stack_frames(meta_pid, level)])
68+
frames = Enum.zip([backtrace_rest, stack_frames(meta_pid, level)])
6969

7070
for {{level, {mod, function, args}}, {level, {mod, line}, bindings}} <- frames do
7171
%Frame{

apps/debug_adapter/test/binding_test.exs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ defmodule ElixirLS.DebugAdapter.BindingTest do
2828

2929
test "multiple versions" do
3030
assert [{:asd, "b"}] ==
31-
Binding.to_elixir_variable_names([{:_asd@1, "a"}, {:_asd@12, "b"}, {:_asd@11, "c"}])
31+
Binding.to_elixir_variable_names([
32+
{:_asd@1, "a"},
33+
{:_asd@12, "b"},
34+
{:_asd@11, "c"}
35+
])
3236
end
3337

3438
test "filter _" do

apps/elixir_ls_utils/lib/launch.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ defmodule ElixirLS.Utils.Launch do
2828

2929
load_dot_config()
3030

31-
# as of 1.15 mix supports two environment variables MIX_QUIET and MIX_DEBUG
31+
# as of 1.18 mix supports environment variables MIX_QUIET, MIX_DEBUG, MIX_PROFILE
3232
# that are not important for our use cases
3333

3434
:ok

apps/elixir_ls_utils/test/complete_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ defmodule ElixirLS.Utils.CompletionEngineTest do
10291029

10301030
# local call on var
10311031

1032-
if Version.match?(System.version(), "< 1.16.0-dev") do
1032+
if Version.match?(System.version(), "< 1.16.0") do
10331033
assert [] == expand(~c"asd.(")
10341034
assert [] == expand(~c"@asd.(")
10351035
else

apps/elixir_ls_utils/test/support/mix_test.case.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,13 @@ defmodule ElixirLS.Utils.MixTest.Case do
8989

9090
defmacro in_fixture(dir, which, block) do
9191
module = inspect(__CALLER__.module)
92-
function = Atom.to_string(elem(__CALLER__.function, 0))
92+
93+
function =
94+
case __CALLER__.function do
95+
{f, _a} -> Atom.to_string(f)
96+
nil -> nil
97+
end
98+
9399
tmp = Path.join(module, function)
94100

95101
quote do

apps/language_server/lib/language_server/ast_utils.ex

Lines changed: 58 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# This code has originally been a part of https://github.com/elixir-lsp/elixir_sense
22

3-
# Copyright (c) 2017 Marlus Saraiva
4-
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5-
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6-
73
defmodule ElixirLS.LanguageServer.AstUtils do
84
import ElixirLS.LanguageServer.Protocol
95
alias ElixirLS.LanguageServer.SourceFile
@@ -14,24 +10,40 @@ defmodule ElixirLS.LanguageServer.AstUtils do
1410
def node_range(node, options \\ [])
1511
def node_range(atom, _options) when is_atom(atom), do: nil
1612

17-
def node_range([{{:__block__, _, [_]} = first, _} | _] = list, _options) do
18-
case List.last(list) do
19-
{_, last} ->
20-
case {node_range(first), node_range(last)} do
21-
{range(start_line, start_character, _, _), range(_, _, end_line, end_character)} ->
22-
range(start_line, start_character, end_line, end_character)
13+
def node_range([{{:__block__, meta, [_]} = first, _} | _] = list, _options) do
14+
if Keyword.get(meta, :format) == :keyword or Keyword.has_key?(meta, :assoc) or
15+
Version.match?(System.version(), "< 1.18.0-dev") do
16+
case List.last(list) do
17+
{_, last} ->
18+
case {node_range(first), node_range(last)} do
19+
{range(start_line, start_character, _, _), range(_, _, end_line, end_character)} ->
20+
range(start_line, start_character, end_line, end_character)
2321

24-
_ ->
25-
nil
26-
end
22+
_ ->
23+
nil
24+
end
2725

28-
_ ->
29-
nil
26+
_ ->
27+
nil
28+
end
3029
end
3130
end
3231

3332
def node_range(list, _options) when is_list(list), do: nil
3433

34+
def node_range({{:__block__, meta, [_]} = first, last}, _options) do
35+
if Keyword.get(meta, :format) == :keyword or Keyword.has_key?(meta, :assoc) or
36+
Version.match?(System.version(), "< 1.18.0-dev") do
37+
case {node_range(first), node_range(last)} do
38+
{range(start_line, start_character, _, _), range(_, _, end_line, end_character)} ->
39+
range(start_line, start_character, end_line, end_character)
40+
41+
_ ->
42+
nil
43+
end
44+
end
45+
end
46+
3547
def node_range({:__block__, meta, args} = _ast, _options) do
3648
line = Keyword.get(meta, :line)
3749
column = Keyword.get(meta, :column)
@@ -62,6 +74,18 @@ defmodule ElixirLS.LanguageServer.AstUtils do
6274
# 2 element tuple
6375
{end_location[:line] - 1, end_location[:column] - 1 + 1}
6476

77+
match?(kind when kind in [:atom, :keyword], Keyword.get(meta, :format)) ->
78+
[literal] = args
79+
80+
modifier =
81+
if literal in [true, false, nil] do
82+
1
83+
else
84+
0
85+
end
86+
87+
get_literal_end(literal, {line, column + modifier}, nil)
88+
6589
match?([_], args) ->
6690
[literal] = args
6791
delimiter = meta[:delimiter]
@@ -96,10 +120,12 @@ defmodule ElixirLS.LanguageServer.AstUtils do
96120
line = Keyword.get(meta, :line) - 1
97121
column = Keyword.get(meta, :column) - 1
98122
{end_line, end_column} = get_eoe_by_formatting(ast, {line, column}, options)
99-
# on elixir 1.15+ formatter changes charlist '' to ~c"" sigil so we need to correct columns
123+
124+
# on elixir 1.15-1.17 formatter changes charlist '' to ~c"" sigil so we need to correct columns
100125
# if charlist is single line
101126
correction =
102-
if end_line == line and Version.match?(System.version(), ">= 1.15.0-dev") do
127+
if end_line == line and Version.match?(System.version(), ">= 1.15.0-dev") and
128+
Version.match?(System.version(), "< 1.18.0-dev") do
103129
2
104130
else
105131
0
@@ -165,18 +191,24 @@ defmodule ElixirLS.LanguageServer.AstUtils do
165191
nil
166192
end
167193

168-
match?({:., _, [Kernel, :to_string]}, form) ->
169-
{line, column}
194+
match?({:., _meta, [Kernel, :to_string]}, form) ->
195+
if Keyword.get(meta, :from_interpolation) ||
196+
Version.match?(System.version(), "< 1.16.0-dev") do
197+
{line, column}
198+
end
170199

171-
match?({:., _, [Access, :get]}, form) and match?([_ | _], args) ->
172-
[arg | _] = args
200+
match?({:., _meta, [Access, :get]}, form) and match?([_ | _], args) ->
201+
if Keyword.get(meta, :from_brackets) ||
202+
Version.match?(System.version(), "< 1.16.0-dev") do
203+
[arg | _] = args
173204

174-
case node_range(arg) do
175-
range(line, column, _, _) ->
176-
{line, column}
205+
case node_range(arg) do
206+
range(line, column, _, _) ->
207+
{line, column}
177208

178-
nil ->
179-
nil
209+
nil ->
210+
nil
211+
end
180212
end
181213

182214
match?({:., _, [_ | _]}, form) ->

apps/language_server/lib/language_server/diagnostics.ex

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,14 @@ defmodule ElixirLS.LanguageServer.Diagnostics do
472472
for typing_trace <- typing_traces, trace <- typing_trace.traces do
473473
case typing_trace.type do
474474
:variable ->
475-
line = trace.meta |> Keyword.get(:line, 1)
476-
column = trace.meta |> Keyword.get(:column, 1)
475+
{line, column} =
476+
case trace do
477+
%{meta: meta} ->
478+
{Keyword.get(meta, :line, 1), Keyword.get(meta, :column, 1)}
479+
480+
_ ->
481+
{Keyword.get(trace, :line, 1), Keyword.get(trace, :column, 1)}
482+
end
477483

478484
message = "given type: #{trace.formatted_type}"
479485

apps/language_server/lib/language_server/dialyzer/manifest.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,10 @@ defmodule ElixirLS.LanguageServer.Dialyzer.Manifest do
167167
modules_to_paths =
168168
for app <- @erlang_apps ++ @elixir_apps,
169169
path <-
170-
Path.join([SourceFile.Path.escape_for_wildcard(Application.app_dir(app)), "**/*.beam"])
170+
Path.join([
171+
SourceFile.Path.escape_for_wildcard(Application.app_dir(app)),
172+
"**/*.beam"
173+
])
171174
|> Path.wildcard(),
172175
into: %{},
173176
do: {pathname_to_module(path), path |> String.to_charlist()}

apps/language_server/lib/language_server/markdown_utils.ex

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,17 @@ defmodule ElixirLS.LanguageServer.MarkdownUtils do
142142
"**Delegates to** #{inspect(m)}.#{f}/#{a}"
143143
end
144144

145+
defp get_metadata_entry_md({:behaviours, []}), do: nil
146+
147+
defp get_metadata_entry_md({:behaviours, list})
148+
when is_list(list) do
149+
"**Implements** #{Enum.map_join(list, ", ", &inspect/1)}"
150+
end
151+
152+
defp get_metadata_entry_md({:source_annos, _}), do: nil
153+
154+
defp get_metadata_entry_md({:source_path, _}), do: nil
155+
145156
defp get_metadata_entry_md({:spark_opts, _}), do: nil
146157

147158
defp get_metadata_entry_md({key, value}) do
@@ -404,7 +415,7 @@ defmodule ElixirLS.LanguageServer.MarkdownUtils do
404415
@kernel_special_forms_exports Kernel.SpecialForms.__info__(:macros)
405416
@kernel_exports Kernel.__info__(:macros) ++ Kernel.__info__(:functions)
406417

407-
defp get_module_fun_arity("..///3"), do: {Kernel, :"..//", 3}
418+
defp get_module_fun_arity("..///3"), do: {Kernel, :..//, 3}
408419
defp get_module_fun_arity("../2"), do: {Kernel, :.., 2}
409420
defp get_module_fun_arity("../0"), do: {Kernel, :.., 0}
410421
defp get_module_fun_arity("./2"), do: {Kernel.SpecialForms, :., 2}

0 commit comments

Comments
 (0)