Skip to content

Commit

Permalink
fix: extract module line from debug info on 1.18 (#559)
Browse files Browse the repository at this point in the history
Fixes #558

fix: correctly index imported functions on 1.18

chore: change 1.17.0-dev to 1.17.0

chore(nix): update flake
  • Loading branch information
mhanberg authored Jan 12, 2025
1 parent 67733d7 commit 9b992b0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
zpkgs = zigpkgs.legacyPackages.${system};
beamPackages = pkgs.beam_minimal.packages.erlang_27;
elixir = beamPackages.elixir_1_17;
# example of overriding elixir with whatever you want
# elixir = beamPackages.elixir_1_18.override {
# rev = "f16fb5aa8162794616a738fc6e84bfcdf9892cff";
# sha256 = "sha256-UYWsmih+0z+4tdPhxl2zf+4gUNEgRJR4yyvxVBOgJdQ=";
# };
in
f {inherit system pkgs zpkgs beamPackages elixir;});

Expand All @@ -42,7 +47,7 @@
elixir,
...
}: {
default = pkgs.callPackage ./package.nix { inherit beamPackages elixir; };
default = pkgs.callPackage ./package.nix {inherit beamPackages elixir;};
});

devShells = forAllSystems ({
Expand Down
26 changes: 19 additions & 7 deletions priv/monkey/_next_ls_private_compiler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ defmodule NextLSPrivate.DepTracer do

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

{:debug_info_v1, _, {_, %{line: line, struct: struct}, _}} = :erlang.binary_to_term(bin)
{line, struct} =
case :erlang.binary_to_term(bin) do
{:debug_info_v1, _, {_, %{anno: anno, struct: struct}, _}} ->
{:erl_anno.line(anno), struct}

{:debug_info_v1, _, {_, %{line: line, struct: struct}, _}} ->
{line, struct}
end

Process.send(
parent,
Expand Down Expand Up @@ -125,11 +132,12 @@ defmodule NextLSPrivate.Tracer do
:ok
end

def trace({type, meta, module, func, arity}, env) when type in [:remote_function, :remote_macro, :imported_macro] do
def trace({type, meta, module, func, arity}, env)
when type in [:remote_function, :remote_macro, :imported_macro, :imported_function] do
parent = parent_pid()

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

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

{:debug_info_v1, _, {_, %{line: line, struct: struct}, _}} = :erlang.binary_to_term(bin)
{line, struct} =
case :erlang.binary_to_term(bin) do
{:debug_info_v1, _, {_, %{anno: anno, struct: struct}, _}} ->
{:erl_anno.line(anno), struct}

{:debug_info_v1, _, {_, %{line: line, struct: struct}, _}} ->
{line, struct}
end

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

:error ->
expand_local(meta, fun, args, state, env)

{:error, _} ->
expand_local(meta, fun, args, state, env)
end
Expand Down

0 comments on commit 9b992b0

Please sign in to comment.