From ea963e6054a6bc19aaf9dea43f3f83911d8f7823 Mon Sep 17 00:00:00 2001 From: Mitchell Hanberg Date: Tue, 27 Feb 2024 12:47:35 -0500 Subject: [PATCH] fix(commands,pipe): handle erlang modules --- lib/next_ls/commands/pipe.ex | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/next_ls/commands/pipe.ex b/lib/next_ls/commands/pipe.ex index 76ff8fd8..47b6dbf6 100644 --- a/lib/next_ls/commands/pipe.ex +++ b/lib/next_ls/commands/pipe.ex @@ -77,7 +77,7 @@ defmodule NextLS.Commands.Pipe do defp parse(lines) do lines |> Enum.join("\n") - |> Spitfire.parse() + |> Spitfire.parse(literal_encoder: &{:ok, {:__block__, &2, [&1]}}) |> case do {:error, ast, _errors} -> {:ok, ast} @@ -87,12 +87,6 @@ defmodule NextLS.Commands.Pipe do end end - def decorate(code, range) do - code - |> Sourceror.patch_string([%{range: range, change: &"«#{&1}»"}]) - |> String.trim_trailing() - end - defp make_range(original_ast) do range = Sourceror.get_range(original_ast) @@ -114,7 +108,7 @@ defmodule NextLS.Commands.Pipe do if not is_nil(range) and (match?({{:., _, _}, _, [_ | _]}, node) or - match?({t, _, [_ | _]} when t not in [:., :__aliases__], node)) do + match?({t, _, [_ | _]} when t not in [:., :__aliases__, :__block__, :=], node)) do if Sourceror.compare_positions(range.start, pos) == :lt && Sourceror.compare_positions(range.end, pos) == :gt do {tree, node}