Skip to content

Commit

Permalink
Apply another code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
scottming committed May 25, 2024
1 parent 96efc70 commit 4d9b00f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,17 @@ defmodule Lexical.RemoteControl.CodeMod.Rename.Prepare do
@renamable_modules [Rename.Module]

defp do_resolve(%Analysis{} = analysis, %Position{} = position) do
result =
Enum.find_value(@renamable_modules, fn module ->
result = module.resolve(analysis, position)

if match?({:ok, _, _}, result) do
result
end
end)

if is_nil(result) do
case Entity.resolve(analysis, position) do
{:ok, other, _} ->
Logger.info("Unsupported entity for renaming: #{inspect(other)}")
{:error, :unsupported_entity}

{:error, reason} ->
{:error, reason}
apply_resolve = fn module ->
case module.resolve(analysis, position) do
{:ok, _, _} = result -> result
_ -> false
end
else
result
end

with :error <- Enum.find_value(@renamable_modules, :error, apply_resolve),
{:ok, other, _} <- Entity.resolve(analysis, position) do
Logger.info("Unsupported entity for renaming: #{inspect(other)}")
{:error, :unsupported_entity}
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ defmodule Lexical.RemoteControl.Commands.Reindex do
end

defp entries_for_uri(uri) do
with {:ok, %Document{} = document, %Analysis{} = analysis} <- ensure_document_open(uri),
with {:ok, %Document{} = document, %Analysis{} = analysis} <- ensure_open(uri),
{:ok, entries} <- Indexer.Quoted.index_with_cleanup(analysis) do
{:ok, document.path, entries}
else
Expand All @@ -65,7 +65,7 @@ defmodule Lexical.RemoteControl.Commands.Reindex do
end
end

defp ensure_document_open(uri) do
defp ensure_open(uri) do
case Document.Store.fetch(uri, :analysis) do
{:ok, %Document{} = document, analysis} ->
{:ok, document, analysis}
Expand Down

0 comments on commit 4d9b00f

Please sign in to comment.