Skip to content

Commit bd3d3bb

Browse files
authored
Elixir 1.15 (#898)
* bump elixir_sense to 1.15 compatible version * update dialyxir to 1.3.0 * Add support for def cli in debugger * fix warnings * pass root option correctly * make sure debug info is preserved * add debugger dep to extra apps I'm not sure this is needed * add todo * temporary workaround for broken logger registrations * add workarounds for prunning code paths * fix typo * add missing app apply change from upstream * make hover work with new elixir_sense version * readd dir param * change dialyzer sha * test valid formatter config * fix infocation * fix test * make sure doc chunks are generated * remove not needed tests * fix test * add logger handler * fix tests * insert needed requires as additional text edits skip completions that would need to alter imports * reinstall log handler after loading config * resolve todo * address todo * fix logger format * run formatter * drop support for elixir 1.12 * remove pre 1.13 code * add missing app * fix function invocation * remove unused code * logger registration in tests * Revert "remove unused code" This reverts commit b0a3bb0. * Revert "remove pre 1.13 code" This partially reverts commit 5164b2b. * port elixir changes related to multiletter sigils * address todo * fix flaky test * fix flaky tests fix logger config reset in build * format * fix crash in completions * fix crash in hover * remove sourceror dependency it proved to be problematic * do not start erlang debugger * add version check * do not call mix local on 1.15 * run formatter
1 parent cb2bbf0 commit bd3d3bb

Some content is hidden

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

44 files changed

+580
-364
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
include:
19-
- elixir: 1.12.x
20-
otp: 22.x
21-
- elixir: 1.12.x
22-
otp: 23.x
2319
- elixir: 1.13.x
2420
otp: 22.x
2521
- elixir: 1.13.x
@@ -56,10 +52,6 @@ jobs:
5652
fail-fast: false
5753
matrix:
5854
include:
59-
- elixir: 1.12.x
60-
otp: 22.x
61-
- elixir: 1.12.x
62-
otp: 23.x
6355
- elixir: 1.13.x
6456
otp: 22.x
6557
- elixir: 1.13.x

.github/workflows/release-asset.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ jobs:
4646
otp-version: '23.3'
4747
- elixir-version: '1.13'
4848
otp-version: '22.3'
49-
- elixir-version: '1.12'
50-
otp-version: '24.3'
51-
- elixir-version: '1.12'
52-
otp-version: '23.3'
53-
- elixir-version: '1.12'
54-
otp-version: '22.3'
5549
default: true
5650

5751
steps:

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.14.6
1+
0.15.0

apps/elixir_ls_debugger/lib/debugger/cli.ex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@ defmodule ElixirLS.Debugger.CLI do
33
alias ElixirLS.Debugger.{Output, Server}
44

55
def main do
6+
Application.put_env(:elixir, :ansi_enabled, false)
67
WireProtocol.intercept_output(&Output.debuggee_out/1, &Output.debuggee_err/1)
78
Launch.start_mix()
9+
10+
if Version.match?(System.version(), ">= 1.15.0-dev") do
11+
# make sue that debugger modules are in code path
12+
# without starting the app
13+
Mix.ensure_application!(:debugger)
14+
end
15+
816
{:ok, _} = Application.ensure_all_started(:elixir_ls_debugger, :permanent)
917

1018
Output.debugger_console("Started ElixirLS Debugger v#{Launch.debugger_version()}")

apps/elixir_ls_debugger/lib/debugger/server.ex

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -939,14 +939,34 @@ defmodule ElixirLS.Debugger.Server do
939939
# https://github.com/elixir-lang/elixir/blob/v1.14.4/lib/mix/lib/mix/cli.ex#L158
940940
# we assume that mix is already started and has archives and tasks loaded
941941
Launch.reload_mix_env_and_target()
942-
Launch.load_mix_exs()
943-
{task, task_args} = Launch.get_task(List.wrap(task) ++ task_args)
944-
Launch.maybe_change_env_and_target(task)
942+
943+
Mix.ProjectStack.post_config(build_path: ".elixir_ls/debugger/build")
944+
945+
Mix.ProjectStack.post_config(
946+
test_elixirc_options: [
947+
docs: true,
948+
debug_info: true
949+
]
950+
)
951+
952+
Mix.ProjectStack.post_config(prune_code_paths: false)
953+
954+
Code.put_compiler_option(:docs, true)
955+
Code.put_compiler_option(:debug_info, true)
956+
957+
args = List.wrap(task) ++ task_args
958+
Launch.load_mix_exs(args)
959+
project = Mix.Project.get()
960+
{task, task_args} = Launch.get_task(args, project)
961+
Launch.maybe_change_env_and_target(task, project)
945962

946963
Output.debugger_console("Running with MIX_ENV: #{Mix.env()} MIX_TARGET: #{Mix.target()}\n")
947964

948965
Mix.Task.run("loadconfig")
949966

967+
# make sure ANSI is disabled
968+
Application.put_env(:elixir, :ansi_enabled, false)
969+
950970
unless is_list(task_args) and "--no-compile" in task_args do
951971
case Mix.Task.run("compile", ["--ignore-module-conflict"]) do
952972
{:error, _} ->

apps/elixir_ls_debugger/mix.exs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ defmodule ElixirLS.Debugger.Mixfile do
66
|> File.read!()
77
|> String.trim()
88

9+
@dep_versions __DIR__
10+
|> Path.join("../../dep_versions.exs")
11+
|> Code.eval_file()
12+
|> elem(0)
13+
914
def project do
1015
[
1116
app: :elixir_ls_debugger,
@@ -14,7 +19,7 @@ defmodule ElixirLS.Debugger.Mixfile do
1419
config_path: "../../config/config.exs",
1520
deps_path: "../../deps",
1621
lockfile: "../../mix.lock",
17-
elixir: ">= 1.12.0",
22+
elixir: ">= 1.13.0",
1823
build_embedded: false,
1924
start_permanent: true,
2025
build_per_environment: false,
@@ -27,16 +32,16 @@ defmodule ElixirLS.Debugger.Mixfile do
2732
end
2833

2934
def application do
30-
[mod: {ElixirLS.Debugger, []}, extra_applications: [:mix]]
35+
[mod: {ElixirLS.Debugger, []}, extra_applications: []]
3136
end
3237

3338
defp deps do
3439
[
35-
{:elixir_sense,
36-
github: "elixir-lsp/elixir_sense", ref: "71efd1e2efbac43e6c98c525cc879ddd747ac62e"},
40+
{:elixir_sense, github: "elixir-lsp/elixir_sense", ref: @dep_versions[:elixir_sense]},
3741
{:elixir_ls_utils, in_umbrella: true},
38-
{:jason_v, github: "elixir-lsp/jason", ref: "c81537e2a5e1acacb915cf339fe400357e3c2aaa"},
39-
{:dialyxir_vendored, github: "elixir-lsp/dialyxir", ref: "896fa45817c6a1be8ec408577c88ab52c27f6851", runtime: false}
42+
{:jason_v, github: "elixir-lsp/jason", ref: @dep_versions[:jason_v]},
43+
{:dialyxir_vendored,
44+
github: "elixir-lsp/dialyxir", ref: @dep_versions[:dialyxir_vendored], runtime: false}
4045
]
4146
end
4247
end

apps/elixir_ls_debugger/test/debugger_test.exs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,8 +1729,13 @@ defmodule ElixirLS.Debugger.ServerTest do
17291729
Server.receive_packet(server, request(6, "threads", %{}))
17301730
assert_receive(response(_, 6, "threads", %{"threads" => threads}), 1_000)
17311731

1732-
assert Enum.find(threads, &(&1["id"] == thread_id))["name"] ==
1733-
":proc_lib.init_p/5 #{:erlang.pid_to_list(pid)}"
1732+
if Version.match?(System.version(), ">= 1.15.0-dev") do
1733+
assert Enum.find(threads, &(&1["id"] == thread_id))["name"] ==
1734+
"Task.Supervised.noreply/4 #{:erlang.pid_to_list(pid)}"
1735+
else
1736+
assert Enum.find(threads, &(&1["id"] == thread_id))["name"] ==
1737+
":proc_lib.init_p/5 #{:erlang.pid_to_list(pid)}"
1738+
end
17341739

17351740
send(pid, :done)
17361741

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
Application.put_env(:elixir_ls_debugger, :test_mode, true)
22
ExUnit.start(exclude: [pending: true])
3+
4+
if Version.match?(System.version(), ">= 1.15.0-dev") do
5+
# make sue that debugger modules are in code path
6+
# without starting the app
7+
Mix.ensure_application!(:debugger)
8+
end

apps/elixir_ls_utils/lib/launch.ex

Lines changed: 77 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ defmodule ElixirLS.Utils.Launch do
33
@compiled_otp_version System.otp_release()
44

55
def start_mix do
6+
if Version.match?(System.version(), "< 1.15.0-dev") do
7+
# since 1.15 Mix.start() calls append_archives() and append_paths()
8+
Mix.Local.append_archives()
9+
Mix.Local.append_paths()
10+
end
11+
612
Mix.start()
7-
Mix.Local.append_archives()
8-
Mix.Local.append_paths()
13+
914
true = Mix.Hex.ensure_installed?(false)
1015
# when running via mix install script mix starts and stops hex
1116
# we need to make sure it's started
@@ -23,7 +28,7 @@ defmodule ElixirLS.Utils.Launch do
2328

2429
load_dot_config()
2530

26-
# as of 1.14 mix supports two environment variables MIX_QUIET and MIX_DEBUG
31+
# as of 1.15 mix supports two environment variables MIX_QUIET and MIX_DEBUG
2732
# that are not important for our use cases
2833

2934
:ok
@@ -71,25 +76,23 @@ defmodule ElixirLS.Utils.Launch do
7176
end
7277
end
7378

74-
def load_mix_exs() do
79+
def load_mix_exs(args) do
7580
file = ElixirLS.Utils.MixfileHelpers.mix_exs()
7681

7782
if File.regular?(file) do
78-
# TODO elixir 1.15 calls
79-
# Mix.ProjectStack.post_config(state_loader: {:cli, List.first(args)})
80-
# added in https://github.com/elixir-lang/elixir/commit/9e07da862784ac7d18a1884141c49ab049e61691
81-
# def cli
82-
# do we need that?
83+
if Version.match?(System.version(), ">= 1.15.0-dev") do
84+
Mix.ProjectStack.post_config(state_loader: {:cli, List.first(args)})
85+
end
86+
8387
old_undefined = Code.get_compiler_option(:no_warn_undefined)
8488
Code.put_compiler_option(:no_warn_undefined, :all)
8589
Code.compile_file(file)
8690
Code.put_compiler_option(:no_warn_undefined, old_undefined)
8791
end
8892
end
8993

90-
# TODO add support for def cli
91-
def get_task(["-" <> _ | _]) do
92-
task = "mix #{Mix.Project.config()[:default_task]}"
94+
def get_task(["-" <> _ | _], project) do
95+
task = "mix #{default_task(project)}"
9396

9497
Mix.shell().error(
9598
"** (Mix) Mix only recognizes the options --help and --version.\n" <>
@@ -100,31 +103,38 @@ defmodule ElixirLS.Utils.Launch do
100103
exit({:shutdown, 1})
101104
end
102105

103-
def get_task([h | t]) do
106+
def get_task([h | t], _project) do
104107
{h, t}
105108
end
106109

107-
def get_task([]) do
108-
case Mix.Project.get() do
109-
nil ->
110-
Mix.shell().error(
111-
"** (Mix) \"mix\" with no arguments must be executed in a directory with a mix.exs file"
112-
)
110+
def get_task([], nil) do
111+
Mix.shell().error(
112+
"** (Mix) \"mix\" with no arguments must be executed in a directory with a mix.exs file"
113+
)
113114

114-
display_usage()
115-
exit({:shutdown, 1})
115+
display_usage()
116+
exit({:shutdown, 1})
117+
end
116118

117-
_ ->
118-
{Mix.Project.config()[:default_task], []}
119+
def get_task([], project) do
120+
{default_task(project), []}
121+
end
122+
123+
defp default_task(project) do
124+
if function_exported?(project, :cli, 0) do
125+
project.cli()[:default_task] || "run"
126+
else
127+
# TODO: Deprecate default_task in v1.19
128+
Mix.Project.config()[:default_task] || "run"
119129
end
120130
end
121131

122-
def maybe_change_env_and_target(task) do
132+
def maybe_change_env_and_target(task, project) do
123133
task = String.to_atom(task)
124134
config = Mix.Project.config()
125135

126-
env = preferred_cli_env(task, config)
127-
target = preferred_cli_target(task, config)
136+
env = preferred_cli_env(project, task, config)
137+
target = preferred_cli_target(project, task, config)
128138
env && Mix.env(env)
129139
target && Mix.target(target)
130140

@@ -133,23 +143,59 @@ defmodule ElixirLS.Utils.Launch do
133143
end
134144
end
135145

146+
def preferred_cli_env(task) when is_atom(task) or is_binary(task) do
147+
case Mix.Task.get(task) do
148+
nil ->
149+
nil
150+
151+
module ->
152+
case List.keyfind(module.__info__(:attributes), :preferred_cli_env, 0) do
153+
{:preferred_cli_env, [setting]} ->
154+
IO.warn(
155+
"""
156+
setting @preferred_cli_env is deprecated inside Mix tasks.
157+
Please remove it from #{inspect(module)} and set your preferred environment in mix.exs instead:
158+
159+
def cli do
160+
[
161+
preferred_envs: [docs: "docs"]
162+
]
163+
end
164+
""",
165+
[]
166+
)
167+
168+
setting
169+
170+
_ ->
171+
nil
172+
end
173+
end
174+
end
175+
136176
defp reload_project() do
137177
if project = Mix.Project.pop() do
138178
%{name: name, file: file} = project
139179
Mix.Project.push(name, file)
140180
end
141181
end
142182

143-
defp preferred_cli_env(task, config) do
144-
if System.get_env("MIX_ENV") do
183+
# TODO: Deprecate preferred_cli_env in v1.19
184+
defp preferred_cli_env(project, task, config) do
185+
if function_exported?(project, :cli, 0) || System.get_env("MIX_ENV") do
145186
nil
146187
else
147-
config[:preferred_cli_env][task] || Mix.Task.preferred_cli_env(task)
188+
config[:preferred_cli_env][task] || preferred_cli_env(task)
148189
end
149190
end
150191

151-
defp preferred_cli_target(task, config) do
152-
config[:preferred_cli_target][task]
192+
# TODO: Deprecate preferred_cli_target in v1.19
193+
defp preferred_cli_target(project, task, config) do
194+
if function_exported?(project, :cli, 0) || System.get_env("MIX_TARGET") do
195+
nil
196+
else
197+
config[:preferred_cli_target][task]
198+
end
153199
end
154200

155201
defp display_usage do

apps/elixir_ls_utils/lib/minimum_version.ex

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,11 @@ defmodule ElixirLS.Utils.MinimumVersion do
1111
end
1212

1313
def check_elixir_version do
14-
if Version.match?(System.version(), ">= 1.12.0") do
15-
otp_release = String.to_integer(System.otp_release())
16-
17-
if Version.match?(System.version(), "< 1.13.0") and otp_release == 24 do
18-
# see https://github.com/elixir-lang/elixir/pull/11158#issuecomment-981583298
19-
{:error,
20-
"Elixir 1.12 is not supported on OTP 24. (Currently running v#{System.version()} on OTP #{otp_release})"}
21-
else
22-
:ok
23-
end
14+
if Version.match?(System.version(), ">= 1.13.0") do
15+
:ok
2416
else
2517
{:error,
26-
"Elixir versions below 1.12.0 are not supported. (Currently running v#{System.version()})"}
18+
"Elixir versions below 1.13.0 are not supported. (Currently running v#{System.version()})"}
2719
end
2820
end
2921
end

0 commit comments

Comments
 (0)