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

fix: extract module line from debug info on 1.18 #559

Merged
merged 4 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading