From c6cf448cb15af24a949b77c8587bf9964f3014a8 Mon Sep 17 00:00:00 2001 From: Mitchell Hanberg Date: Sun, 12 Jan 2025 16:18:27 -0500 Subject: [PATCH 1/4] fix: extract module line from debug info on 1.18 Fixes #558 --- priv/monkey/_next_ls_private_compiler.ex | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/priv/monkey/_next_ls_private_compiler.ex b/priv/monkey/_next_ls_private_compiler.ex index 60f301ae..fd7eba8a 100644 --- a/priv/monkey/_next_ls_private_compiler.ex +++ b/priv/monkey/_next_ls_private_compiler.ex @@ -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, @@ -193,8 +200,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, {:tracer, @@ -1361,9 +1374,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 From 070c113458f32cbdc1b54b9ee0cb0f9821441eaa Mon Sep 17 00:00:00 2001 From: Mitchell Hanberg Date: Sun, 12 Jan 2025 16:19:56 -0500 Subject: [PATCH 2/4] fix: correctly index imported functions on 1.18 --- priv/monkey/_next_ls_private_compiler.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/priv/monkey/_next_ls_private_compiler.ex b/priv/monkey/_next_ls_private_compiler.ex index fd7eba8a..c89851d9 100644 --- a/priv/monkey/_next_ls_private_compiler.ex +++ b/priv/monkey/_next_ls_private_compiler.ex @@ -132,7 +132,8 @@ 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 = @@ -208,6 +209,7 @@ defmodule NextLSPrivate.Tracer do {:debug_info_v1, _, {_, %{line: line, struct: struct}, _}} -> {line, struct} end + Process.send( parent, {:tracer, From 97c41448feb3cc7899b47ea2864339990d8199ec Mon Sep 17 00:00:00 2001 From: Mitchell Hanberg Date: Sun, 12 Jan 2025 16:20:31 -0500 Subject: [PATCH 3/4] chore: change 1.17.0-dev to 1.17.0 --- priv/monkey/_next_ls_private_compiler.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/priv/monkey/_next_ls_private_compiler.ex b/priv/monkey/_next_ls_private_compiler.ex index c89851d9..399856d5 100644 --- a/priv/monkey/_next_ls_private_compiler.ex +++ b/priv/monkey/_next_ls_private_compiler.ex @@ -137,7 +137,7 @@ defmodule NextLSPrivate.Tracer 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] From 8816f6abce137de5495534110141ae11d8bcda7b Mon Sep 17 00:00:00 2001 From: Mitchell Hanberg Date: Sun, 12 Jan 2025 16:20:41 -0500 Subject: [PATCH 4/4] chore(nix): update flake --- flake.lock | 6 +++--- flake.nix | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/flake.lock b/flake.lock index b99d5d17..15f815b9 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1720418205, - "narHash": "sha256-cPJoFPXU44GlhWg4pUk9oUPqurPlCFZ11ZQPk21GTPU=", + "lastModified": 1735471104, + "narHash": "sha256-0q9NGQySwDQc7RhAV2ukfnu7Gxa5/ybJ2ANT8DQrQrs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "655a58a72a6601292512670343087c2d75d859c1", + "rev": "88195a94f390381c6afcdaa933c2f6ff93959cb4", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 3b669825..d831f240 100644 --- a/flake.nix +++ b/flake.nix @@ -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;}); @@ -42,7 +47,7 @@ elixir, ... }: { - default = pkgs.callPackage ./package.nix { inherit beamPackages elixir; }; + default = pkgs.callPackage ./package.nix {inherit beamPackages elixir;}; }); devShells = forAllSystems ({