Skip to content

Commit

Permalink
fix(commands,pipe): handle erlang modules (#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhanberg committed Feb 27, 2024
1 parent fb6ed2b commit 8b0b7bd
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/next_ls/commands/pipe.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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)

Expand All @@ -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}
Expand Down

0 comments on commit 8b0b7bd

Please sign in to comment.