Skip to content

Commit 9b992b0

Browse files
authored
fix: extract module line from debug info on 1.18 (#559)
Fixes #558 fix: correctly index imported functions on 1.18 chore: change 1.17.0-dev to 1.17.0 chore(nix): update flake
1 parent 67733d7 commit 9b992b0

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

Diff for: flake.lock

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: flake.nix

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
zpkgs = zigpkgs.legacyPackages.${system};
2626
beamPackages = pkgs.beam_minimal.packages.erlang_27;
2727
elixir = beamPackages.elixir_1_17;
28+
# example of overriding elixir with whatever you want
29+
# elixir = beamPackages.elixir_1_18.override {
30+
# rev = "f16fb5aa8162794616a738fc6e84bfcdf9892cff";
31+
# sha256 = "sha256-UYWsmih+0z+4tdPhxl2zf+4gUNEgRJR4yyvxVBOgJdQ=";
32+
# };
2833
in
2934
f {inherit system pkgs zpkgs beamPackages elixir;});
3035

@@ -42,7 +47,7 @@
4247
elixir,
4348
...
4449
}: {
45-
default = pkgs.callPackage ./package.nix { inherit beamPackages elixir; };
50+
default = pkgs.callPackage ./package.nix {inherit beamPackages elixir;};
4651
});
4752

4853
devShells = forAllSystems ({

Diff for: priv/monkey/_next_ls_private_compiler.ex

+19-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ defmodule NextLSPrivate.DepTracer do
1919

2020
{:ok, {_, [{~c"Dbgi", bin}]}} = :beam_lib.chunks(bytecode, [~c"Dbgi"])
2121

22-
{:debug_info_v1, _, {_, %{line: line, struct: struct}, _}} = :erlang.binary_to_term(bin)
22+
{line, struct} =
23+
case :erlang.binary_to_term(bin) do
24+
{:debug_info_v1, _, {_, %{anno: anno, struct: struct}, _}} ->
25+
{:erl_anno.line(anno), struct}
26+
27+
{:debug_info_v1, _, {_, %{line: line, struct: struct}, _}} ->
28+
{line, struct}
29+
end
2330

2431
Process.send(
2532
parent,
@@ -125,11 +132,12 @@ defmodule NextLSPrivate.Tracer do
125132
:ok
126133
end
127134

128-
def trace({type, meta, module, func, arity}, env) when type in [:remote_function, :remote_macro, :imported_macro] do
135+
def trace({type, meta, module, func, arity}, env)
136+
when type in [:remote_function, :remote_macro, :imported_macro, :imported_function] do
129137
parent = parent_pid()
130138

131139
condition =
132-
if Version.match?(System.version(), ">= 1.17.0-dev") do
140+
if Version.match?(System.version(), ">= 1.17.0") do
133141
is_nil(meta[:column])
134142
else
135143
type == :remote_macro && meta[:closing][:line] != meta[:line]
@@ -193,7 +201,14 @@ defmodule NextLSPrivate.Tracer do
193201

194202
{:ok, {_, [{~c"Dbgi", bin}]}} = :beam_lib.chunks(bytecode, [~c"Dbgi"])
195203

196-
{:debug_info_v1, _, {_, %{line: line, struct: struct}, _}} = :erlang.binary_to_term(bin)
204+
{line, struct} =
205+
case :erlang.binary_to_term(bin) do
206+
{:debug_info_v1, _, {_, %{anno: anno, struct: struct}, _}} ->
207+
{:erl_anno.line(anno), struct}
208+
209+
{:debug_info_v1, _, {_, %{line: line, struct: struct}, _}} ->
210+
{line, struct}
211+
end
197212

198213
Process.send(
199214
parent,
@@ -1361,9 +1376,6 @@ if Version.match?(System.version(), ">= 1.17.0-dev") do
13611376
{:function, module, fun} ->
13621377
expand_remote(meta, module, fun, args, state, env)
13631378

1364-
:error ->
1365-
expand_local(meta, fun, args, state, env)
1366-
13671379
{:error, _} ->
13681380
expand_local(meta, fun, args, state, env)
13691381
end

0 commit comments

Comments
 (0)