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: use literal encoder when using sourceror #380

Merged
merged 1 commit into from
Feb 27, 2024
Merged
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
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
Loading