Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.18 #1147

Merged
merged 39 commits into from
Dec 30, 2024
Merged

1.18 #1147

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
6213038
hide unwanted meta
lukaszsamson Dec 19, 2024
5ce4bf9
remove deprecated calls
lukaszsamson Dec 19, 2024
ead7d2c
fix tests
lukaszsamson Dec 19, 2024
38b8950
bump elixir_sense
lukaszsamson Dec 21, 2024
821d542
fix warning
lukaszsamson Dec 21, 2024
222bcb7
fix tests
lukaszsamson Dec 21, 2024
720c0c7
fix warnings
lukaszsamson Dec 21, 2024
8512037
remove invalid copyright notice
lukaszsamson Dec 21, 2024
cc88cde
remove no longer needed correction
lukaszsamson Dec 21, 2024
f7f8ef4
filter out protocol introspection functions from protocol functions c…
lukaszsamson Dec 21, 2024
cec158f
fix test
lukaszsamson Dec 21, 2024
a61293b
remove not used function
lukaszsamson Dec 21, 2024
f2786fd
workarounf elixir 1.18.0 regression
lukaszsamson Dec 21, 2024
56ff770
return to elixir version
lukaszsamson Dec 21, 2024
7b6a3f5
cache Mix.Project data and make all accesses to it safe from Mix.Stat…
lukaszsamson Oct 29, 2023
7066835
use safe expand
lukaszsamson Dec 21, 2024
a1269e0
use root option
lukaszsamson Dec 21, 2024
272842b
revise mix startup sequence
lukaszsamson Dec 21, 2024
8c74e46
bump elixir_sense
lukaszsamson Dec 22, 2024
8c6fec7
run CI on 1.18
lukaszsamson Dec 22, 2024
496c34c
filter out auto implemented Protocol callbacks
lukaszsamson Dec 23, 2024
58317a5
do not change __deriving__ contrract
lukaszsamson Dec 23, 2024
bfd0694
improve version checks
lukaszsamson Dec 23, 2024
4c4473b
fix test
lukaszsamson Dec 23, 2024
4d93205
suggest record fields from compiled records on 1.18+
lukaszsamson Dec 26, 2024
5cef583
format
lukaszsamson Dec 26, 2024
babfd3e
format behaviours meta
lukaszsamson Dec 26, 2024
8babd3e
update comment
lukaszsamson Dec 26, 2024
27b3f7d
bump elixir_sense
lukaszsamson Dec 26, 2024
f7d03a2
update readme
lukaszsamson Dec 26, 2024
85aad1b
handle new parser metadata in selection ranges
lukaszsamson Dec 28, 2024
b6c74aa
uncomment test for case working on 1.18
lukaszsamson Dec 29, 2024
57ca8ca
update matrix
lukaszsamson Dec 29, 2024
4290d7e
fix test
lukaszsamson Dec 29, 2024
3eb8530
fix tests
lukaszsamson Dec 29, 2024
d57bcb7
bump elixir_sense
lukaszsamson Dec 29, 2024
abad1f8
format
lukaszsamson Dec 29, 2024
6572c64
fix crash on elixir < 1.16
lukaszsamson Dec 29, 2024
91a38e6
fix another crash on < 1.16
lukaszsamson Dec 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ jobs:
- elixir: 1.17.x
otp: 27.x
tests_may_fail: false
# https://github.com/erlef/setup-beam/issues/314
# - elixir: 1.18.x
# otp: 25.x
# tests_may_fail: false
- elixir: 1.18.x
otp: 26.x
tests_may_fail: false
- elixir: 1.18.x
otp: 27.x
tests_may_fail: false
env:
MIX_ENV: test
steps:
Expand All @@ -80,7 +90,8 @@ jobs:
mix local.hex --force
mix local.rebar --force
mix deps.get --only test
- run: mix test || ${{ matrix.tests_may_fail }}
- run: mix test
continue-on-error: ${{ matrix.tests_may_fail }}

mix_test_windows:
name: mix test windows (Elixir ${{matrix.elixir}} | Erlang/OTP ${{matrix.otp}})
Expand Down Expand Up @@ -126,6 +137,16 @@ jobs:
- elixir: 1.17.x
otp: 27.x
tests_may_fail: false
# https://github.com/erlef/setup-beam/issues/314
# - elixir: 1.18.x
# otp: 25.x
# tests_may_fail: false
- elixir: 1.18.x
otp: 26.x
tests_may_fail: false
- elixir: 1.18.x
otp: 27.x
tests_may_fail: false
env:
MIX_ENV: test
steps:
Expand All @@ -143,14 +164,15 @@ jobs:
mix local.rebar --force
mix deps.get --only test
- run: mix test
continue-on-error: ${{ matrix.tests_may_fail }}

static_analysis:
name: static analysis (Elixir ${{matrix.elixir}} | Erlang/OTP ${{matrix.otp}})
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- elixir: 1.17.x
- elixir: 1.18.x
otp: 27.x
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-asset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Set up BEAM
uses: erlef/setup-beam@v1
with:
elixir-version: 1.17.x
elixir-version: 1.18.x
otp-version: 27.x

- name: Install dependencies
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ ElixirLS generally aims to support all supported versions of Elixir on all compa
| 22 | 1.13 | Yes | Erlang docs not working (requires EIP 48) |
| 23 | 1.13 - 1.14 | Yes | None |
| 24 | 1.13 - 1.16 | Yes | None |
| 25 | 1.13.4 - 1.17 | Yes | None |
| 25 | 1.13.4 - 1.18 | Yes | None |
| 26.0.0 - 26.0.1 | any | No | [#886](https://github.com/elixir-lsp/elixir-ls/issues/886) |
| 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) |
| >= 26.2.0 | 1.14.5 - 1.17 | Yes | None |
| 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) |
| >= 26.2.0 | 1.14.5 - 1.18 | Yes | None |
| any | 1.15.5 | Yes | Broken formatter [#975](https://github.com/elixir-lsp/elixir-ls/issues/975) |
| 27 | 1.17 | Yes | None |
| 27 | 1.17 - 1.18 | Yes | None |

### Version management

Expand Down
2 changes: 1 addition & 1 deletion apps/debug_adapter/lib/debug_adapter/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@ defmodule ElixirLS.DebugAdapter.Server do
{state, frame_ids} = ensure_frame_ids(state, pid, stack_frames)

stack_frames_json =
for {%Frame{} = stack_frame, frame_id} <- List.zip([stack_frames, frame_ids]) do
for {%Frame{} = stack_frame, frame_id} <- Enum.zip([stack_frames, frame_ids]) do
%{
"id" => frame_id,
"name" => Stacktrace.Frame.name(stack_frame),
Expand Down
2 changes: 1 addition & 1 deletion apps/debug_adapter/lib/debug_adapter/stacktrace.ex
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ defmodule ElixirLS.DebugAdapter.Stacktrace do
[]

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

for {{level, {mod, function, args}}, {level, {mod, line}, bindings}} <- frames do
%Frame{
Expand Down
6 changes: 5 additions & 1 deletion apps/debug_adapter/test/binding_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ defmodule ElixirLS.DebugAdapter.BindingTest do

test "multiple versions" do
assert [{:asd, "b"}] ==
Binding.to_elixir_variable_names([{:_asd@1, "a"}, {:_asd@12, "b"}, {:_asd@11, "c"}])
Binding.to_elixir_variable_names([
{:_asd@1, "a"},
{:_asd@12, "b"},
{:_asd@11, "c"}
])
end

test "filter _" do
Expand Down
2 changes: 1 addition & 1 deletion apps/elixir_ls_utils/lib/launch.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ defmodule ElixirLS.Utils.Launch do

load_dot_config()

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

:ok
Expand Down
2 changes: 1 addition & 1 deletion apps/elixir_ls_utils/test/complete_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ defmodule ElixirLS.Utils.CompletionEngineTest do

# local call on var

if Version.match?(System.version(), "< 1.16.0-dev") do
if Version.match?(System.version(), "< 1.16.0") do
assert [] == expand(~c"asd.(")
assert [] == expand(~c"@asd.(")
else
Expand Down
8 changes: 7 additions & 1 deletion apps/elixir_ls_utils/test/support/mix_test.case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ defmodule ElixirLS.Utils.MixTest.Case do

defmacro in_fixture(dir, which, block) do
module = inspect(__CALLER__.module)
function = Atom.to_string(elem(__CALLER__.function, 0))

function =
case __CALLER__.function do
{f, _a} -> Atom.to_string(f)
nil -> nil
end

tmp = Path.join(module, function)

quote do
Expand Down
84 changes: 58 additions & 26 deletions apps/language_server/lib/language_server/ast_utils.ex
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# This code has originally been a part of https://github.com/elixir-lsp/elixir_sense

# Copyright (c) 2017 Marlus Saraiva
# 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:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

defmodule ElixirLS.LanguageServer.AstUtils do
import ElixirLS.LanguageServer.Protocol
alias ElixirLS.LanguageServer.SourceFile
Expand All @@ -14,24 +10,40 @@ defmodule ElixirLS.LanguageServer.AstUtils do
def node_range(node, options \\ [])
def node_range(atom, _options) when is_atom(atom), do: nil

def node_range([{{:__block__, _, [_]} = first, _} | _] = list, _options) do
case List.last(list) do
{_, last} ->
case {node_range(first), node_range(last)} do
{range(start_line, start_character, _, _), range(_, _, end_line, end_character)} ->
range(start_line, start_character, end_line, end_character)
def node_range([{{:__block__, meta, [_]} = first, _} | _] = list, _options) do
if Keyword.get(meta, :format) == :keyword or Keyword.has_key?(meta, :assoc) or
Version.match?(System.version(), "< 1.18.0-dev") do
case List.last(list) do
{_, last} ->
case {node_range(first), node_range(last)} do
{range(start_line, start_character, _, _), range(_, _, end_line, end_character)} ->
range(start_line, start_character, end_line, end_character)

_ ->
nil
end
_ ->
nil
end

_ ->
nil
_ ->
nil
end
end
end

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

def node_range({{:__block__, meta, [_]} = first, last}, _options) do
if Keyword.get(meta, :format) == :keyword or Keyword.has_key?(meta, :assoc) or
Version.match?(System.version(), "< 1.18.0-dev") do
case {node_range(first), node_range(last)} do
{range(start_line, start_character, _, _), range(_, _, end_line, end_character)} ->
range(start_line, start_character, end_line, end_character)

_ ->
nil
end
end
end

def node_range({:__block__, meta, args} = _ast, _options) do
line = Keyword.get(meta, :line)
column = Keyword.get(meta, :column)
Expand Down Expand Up @@ -62,6 +74,18 @@ defmodule ElixirLS.LanguageServer.AstUtils do
# 2 element tuple
{end_location[:line] - 1, end_location[:column] - 1 + 1}

match?(kind when kind in [:atom, :keyword], Keyword.get(meta, :format)) ->
[literal] = args

modifier =
if literal in [true, false, nil] do
1
else
0
end

get_literal_end(literal, {line, column + modifier}, nil)

match?([_], args) ->
[literal] = args
delimiter = meta[:delimiter]
Expand Down Expand Up @@ -96,10 +120,12 @@ defmodule ElixirLS.LanguageServer.AstUtils do
line = Keyword.get(meta, :line) - 1
column = Keyword.get(meta, :column) - 1
{end_line, end_column} = get_eoe_by_formatting(ast, {line, column}, options)
# on elixir 1.15+ formatter changes charlist '' to ~c"" sigil so we need to correct columns

# on elixir 1.15-1.17 formatter changes charlist '' to ~c"" sigil so we need to correct columns
# if charlist is single line
correction =
if end_line == line and Version.match?(System.version(), ">= 1.15.0-dev") do
if end_line == line and Version.match?(System.version(), ">= 1.15.0-dev") and
Version.match?(System.version(), "< 1.18.0-dev") do
2
else
0
Expand Down Expand Up @@ -165,18 +191,24 @@ defmodule ElixirLS.LanguageServer.AstUtils do
nil
end

match?({:., _, [Kernel, :to_string]}, form) ->
{line, column}
match?({:., _meta, [Kernel, :to_string]}, form) ->
if Keyword.get(meta, :from_interpolation) ||
Version.match?(System.version(), "< 1.16.0-dev") do
{line, column}
end

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

case node_range(arg) do
range(line, column, _, _) ->
{line, column}
case node_range(arg) do
range(line, column, _, _) ->
{line, column}

nil ->
nil
nil ->
nil
end
end

match?({:., _, [_ | _]}, form) ->
Expand Down
10 changes: 8 additions & 2 deletions apps/language_server/lib/language_server/diagnostics.ex
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,14 @@ defmodule ElixirLS.LanguageServer.Diagnostics do
for typing_trace <- typing_traces, trace <- typing_trace.traces do
case typing_trace.type do
:variable ->
line = trace.meta |> Keyword.get(:line, 1)
column = trace.meta |> Keyword.get(:column, 1)
{line, column} =
case trace do
%{meta: meta} ->
{Keyword.get(meta, :line, 1), Keyword.get(meta, :column, 1)}

_ ->
{Keyword.get(trace, :line, 1), Keyword.get(trace, :column, 1)}
end

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ defmodule ElixirLS.LanguageServer.Dialyzer.Manifest do
modules_to_paths =
for app <- @erlang_apps ++ @elixir_apps,
path <-
Path.join([SourceFile.Path.escape_for_wildcard(Application.app_dir(app)), "**/*.beam"])
Path.join([
SourceFile.Path.escape_for_wildcard(Application.app_dir(app)),
"**/*.beam"
])
|> Path.wildcard(),
into: %{},
do: {pathname_to_module(path), path |> String.to_charlist()}
Expand Down
13 changes: 12 additions & 1 deletion apps/language_server/lib/language_server/markdown_utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,17 @@ defmodule ElixirLS.LanguageServer.MarkdownUtils do
"**Delegates to** #{inspect(m)}.#{f}/#{a}"
end

defp get_metadata_entry_md({:behaviours, []}), do: nil

defp get_metadata_entry_md({:behaviours, list})
when is_list(list) do
"**Implements** #{Enum.map_join(list, ", ", &inspect/1)}"
end

defp get_metadata_entry_md({:source_annos, _}), do: nil

defp get_metadata_entry_md({:source_path, _}), do: nil

defp get_metadata_entry_md({:spark_opts, _}), do: nil

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

defp get_module_fun_arity("..///3"), do: {Kernel, :"..//", 3}
defp get_module_fun_arity("..///3"), do: {Kernel, :..//, 3}
defp get_module_fun_arity("../2"), do: {Kernel, :.., 2}
defp get_module_fun_arity("../0"), do: {Kernel, :.., 0}
defp get_module_fun_arity("./2"), do: {Kernel.SpecialForms, :., 2}
Expand Down
Loading
Loading