Skip to content

Commit

Permalink
Apply some code view suggestions to fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
scottming committed Dec 17, 2023
1 parent 65c3550 commit 143d52b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ defmodule Lexical.RemoteControl.CodeIntelligence.Rename do
prefix = "#{entity_string}."

prefix
|> Store.prefix(subject: [:definition, :reference])
|> Store.prefix([])
|> Enum.filter(&(entry_matching?(&1, cursor_entity_string) and has_dots_in_range?(&1)))
|> adjust_range(entity)
end
Expand All @@ -103,7 +103,7 @@ defmodule Lexical.RemoteControl.CodeIntelligence.Rename do
entity_string = inspect(entity)

entity_string
|> Store.exact(subject: [:definition, :reference])
|> Store.exact([])
|> Enum.filter(&entry_matching?(&1, cursor_entity_string))
end

Expand Down Expand Up @@ -156,7 +156,7 @@ defmodule Lexical.RemoteControl.CodeIntelligence.Rename do
defp to_edits_by_uri(results, new_name) do
Enum.group_by(
results,
fn result -> Document.Path.ensure_uri(result.path) end,
&Document.Path.ensure_uri(&1.path),
fn result ->
cursor_entity_length = result.range |> cursor_entity_string() |> String.length()
# e.g: `Parent.|ToBeRenameModule`, we need the start position of `ToBeRenameModule`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ defmodule Lexical.RemoteControl.CodeIntelligence.RenameTest do
end

describe "rename exact module" do
test "succeeds when the cursor on the definition" do
test "succeeds when the cursor is before the definition" do
{:ok, result} =
~q[
defmodule |Foo do
Expand All @@ -57,7 +57,7 @@ defmodule Lexical.RemoteControl.CodeIntelligence.RenameTest do
assert result =~ ~S[defmodule Renamed do]
end

test "succeeds when the cursor on the alias" do
test "succeeds when the cursor is at the alias" do
{:ok, result} =
~q[
defmodule Baz do
Expand All @@ -68,7 +68,7 @@ defmodule Lexical.RemoteControl.CodeIntelligence.RenameTest do
assert result =~ ~S[alias Renamed]
end

test "succeeds when the definition in a nested module" do
test "succeeds when the definition is in a nested module" do
{:ok, result} =
~q[
defmodule TopLevel do
Expand All @@ -93,7 +93,7 @@ defmodule Lexical.RemoteControl.CodeIntelligence.RenameTest do
]
end

test "succeeds when the cursor in the multiple aliases off of single alias" do
test "succeeds when the cursor is in the multiple aliases off of single alias" do
{:ok, result} =
~q[
defmodule TopLevel do
Expand All @@ -108,7 +108,7 @@ defmodule Lexical.RemoteControl.CodeIntelligence.RenameTest do
assert result =~ ~S[ First, Renamed,]
end

test "only rename the aliased when the cursor at the aliased" do
test "only rename the aliased when the cursor is at the aliased" do
{:ok, result} =
~q[
defmodule TopLevel do
Expand All @@ -122,7 +122,7 @@ defmodule Lexical.RemoteControl.CodeIntelligence.RenameTest do
assert result =~ ~S[ Renamed]
end

test "succeeds when the cursor at the alias_ased child" do
test "succeeds when the cursor is at the aliased child" do
{:ok, result} =
~q[
defmodule TopLevel.Foo.Bar do
Expand All @@ -140,7 +140,7 @@ defmodule Lexical.RemoteControl.CodeIntelligence.RenameTest do
assert result =~ ~S[ Parent.Renamed]
end

test "only rename aliased when the cursor at the alias_ased" do
test "only rename aliased when the cursor is at the aliased" do
{:ok, result} =
~q[
defmodule TopLevel.Foo.Bar do
Expand Down Expand Up @@ -172,7 +172,7 @@ defmodule Lexical.RemoteControl.CodeIntelligence.RenameTest do
assert result =~ ~S[defmodule FooTest do]
end

test "shouldn't rename the descendants when the cursor at the end of the module" do
test "shouldn't rename the descendants when the cursor is at the end of the module" do
{:ok, result} = ~q[
defmodule TopLevel.Module do # ✓
end
Expand Down Expand Up @@ -214,7 +214,7 @@ defmodule Lexical.RemoteControl.CodeIntelligence.RenameTest do
assert result =~ ~S[alias TopLevel.Second.Renamed.Module]
end

test "succeeds when there are same module name in the cursor neighborhood" do
test "succeeds when there are same module name is in the cursor neighborhood" do
{:ok, result} =
~q[
defmodule TopLevel.Foo do
Expand Down Expand Up @@ -254,7 +254,7 @@ defmodule Lexical.RemoteControl.CodeIntelligence.RenameTest do
end

describe "rename struct" do
test "succeeds when the cursor on the definition" do
test "succeeds when the cursor is at the definition" do
{:ok, result} =
~q[
defmodule |Foo do
Expand All @@ -272,7 +272,7 @@ defmodule Lexical.RemoteControl.CodeIntelligence.RenameTest do
assert result =~ ~S[%Renamed{}]
end

test "succeeds when the cursor on the reference" do
test "succeeds when the cursor is at the reference" do
{:ok, result} =
~q[
defmodule Foo do
Expand Down

0 comments on commit 143d52b

Please sign in to comment.