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

Add Support for Renaming module #374

Closed
wants to merge 14 commits into from

Conversation

scottming
Copy link
Collaborator

@scottming scottming commented Sep 17, 2023

We need to consider two typical scenarios:

  1. One is renaming an exact entry,
  2. And the other is renaming both the entry and its descendants.

I differentiate between these two scenarios based on the cursor's position. If there are no more child modules after the cursor, for example, in the case of defmodule TopLevel.|Entry, then rename the Entry module.

However, if there are child modules after the cursor, then rename both the Entry module and its descendants.
For example, if the cursor is at defmodule TopLevel.|Entry.Child, and we want to rename it to defmodule TopLevel.Renamed.Child, then TopLevel.Entry.AnotherChild will also be renamed to TopLevel.Renamed.AnotherChild

TODO

  • Add some tests for handlers/rename.ex

@scottming scottming changed the title Rename module Add Support for Renaming module Sep 17, 2023
Copy link
Collaborator

@zachallaun zachallaun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't finished review yet, but have to run for a bit and wanted to get this thought down: Does this handle renaming an alias? For instance, if I have:

alias Future.Code, as: Code

And then I want to rename Code to MyFutureCode (contrived example), the rename should only occur within the scope that the alias is valid. I think this is probably something that needs to be handled/considered by the indexer -- just want to make sure it is.

@zachallaun
Copy link
Collaborator

Please ignore this:

Does this handle renaming an alias?

Made my way to the tests and I see that it does :) Apologies for not reading those first.

@scottming scottming marked this pull request as draft September 19, 2023 14:15
@scottming scottming force-pushed the rename-module branch 2 times, most recently from 43deb94 to 2b64396 Compare December 3, 2023 09:20
@scottming scottming marked this pull request as ready for review December 3, 2023 09:20
@scottming
Copy link
Collaborator Author

scottming commented Dec 4, 2023

I think this pull request is ready for review. The core of the renaming process is to identify eligible candidates, adjust the range, and combine them into a structure of %{ uri => changes }. @scohen @zachallaun

Comment on lines 136 to 131
defp resolve_entity_range(uri, location, entity) do
{line, character} = location

with {:ok, document} <- Document.Store.open_temporary(uri),
position = Position.new(document, line, character),
analysis = Ast.analyze(document),
{:ok, result, range} <- resolve_module(analysis, position) do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can make sure that analysis is cached using the new document store derived data. Assuming the other suggestions I made are incorporated:

Suggested change
defp resolve_entity_range(uri, location, entity) do
{line, character} = location
with {:ok, document} <- Document.Store.open_temporary(uri),
position = Position.new(document, line, character),
analysis = Ast.analyze(document),
{:ok, result, range} <- resolve_module(analysis, position) do
defp resolve_entity_range(uri, position, entity) do
with {:ok, _} <- Document.Store.open_temporary(uri),
{:ok, document, analysis} <- Document.Store.fetch(uri, :analysis),
{:ok, result, range} <- Entity.resolve(analysis, position, [:module, :struct]) do

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to be sure that the analysis is also purged when a temporarily opened document is closed.

Copy link
Collaborator Author

@scottming scottming Dec 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scohen Does this point relate to this PR? I don't quite understand this comment. Could you elaborate?

@spec rename(Analysis.t(), Position.t(), String.t()) ::
{:ok, %{Lexical.uri() => [Edit.t()]}} | {:error, term()}
def rename(%Analysis{} = analysis, %Position{} = position, new_name) do
with {:ok, entity, range} <- resolve_module(analysis, position) do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about replacing resolve_module with a new Entity.resolve/3 API that would work like:

Suggested change
with {:ok, entity, range} <- resolve_module(analysis, position) do
with {:ok, entity, range} <- Entity.resolve(analysis, position, [:module, :struct]) do

Inside Entity, I think the implementation would just be:

def resolve(%Analysis{} = analysis, %Position{} = position, kinds) when is_list(kinds) do
  case resolve(analysis, position) do
    {:error, _} = error ->
      error

    entity when is_tuple(entity) and elem(entity, 0) in kinds ->
      entity

    _ ->
      {:error, :not_found}
  end
end

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can do this in the future, but for now, I prefer to keep it in this file, as this API is not used elsewhere.

Comment on lines 89 to 92
|> Enum.filter(fn result ->
range_text = range_text(result.range)
String.contains?(range_text, cursor_entity_string)
end)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This particular filter happens at least three times in this file, I think -- probably worth extracting into a helper.

Suggested change
|> Enum.filter(fn result ->
range_text = range_text(result.range)
String.contains?(range_text, cursor_entity_string)
end)
|> entries_matching(cursor_entity_string)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha, Just twice, but I prefer to abstract a function for the item

setup_all do
project = project()
RemoteControl.set_project(project)
start_supervised!(Document.Store)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be necessary to use Document.Store.fetch(uri, :analysis) as I suggested elsewhere.

Suggested change
start_supervised!(Document.Store)
start_supervised!(Lexical.Server.Application.document_store_child_spec())

Copy link
Collaborator Author

@scottming scottming Dec 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good suggestion, but we can't simply use that function because currently in the remote_control app context.

apps/server/lib/lexical/server/provider/handlers/rename.ex Outdated Show resolved Hide resolved
@scottming scottming force-pushed the rename-module branch 2 times, most recently from ee3b3e6 to da6b905 Compare December 9, 2023 10:25
@scottming
Copy link
Collaborator Author

PrepareRename and Rename in Vscode

CleanShot.2023-12-09.at.18.33.47.mp4

in Neovim

CleanShot.2023-12-09.at.18.31.30-converted.mp4

@zachallaun I've applied most of your suggestions. Please review them again when you have time. If there are no other issues, then I will add some integration tests for the handlers.

Copy link
Collaborator

@scohen scohen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main concern her is if we could simplify things by making subjects charlists.

Comment on lines 46 to 64
# Users won't always want to rename descendants of a module.
# For instance, when there are no more submodules after the cursor.
# like: `defmodule TopLevel.Mo|dule do`
# in most cases, users only want to rename the module itself.
#
# However, there's an exception when the cursor is in the middle,
# such as `Top.Mo|dule.ChildModule`. If we rename it to `Top.Renamed.Child`,
# it would be natural to also rename `Module.ChildModule` to `Renamed.Child`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't you figure out which canonical module you want to rename, and find all instances of that? Possibly using a substring match that we'd have to build. Then it's just a matter of doing Store.starts_with("Foo.Bar.Baz", :module)

Comment on lines 84 to 90
defp cursor_entity_string(range) do
# Parent.|Module -> Module
range
|> range_text()
|> String.split(".")
|> List.last()
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should go in ast/module.ex, and should be called something like: local_module_name

Comment on lines 28 to 34
defkey :by_prefix, [
:prefix,
:type,
:subtype,
:elixir_version,
:erlang_version
]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you added a key and a field, you need to increment the schema and make a migration.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you referring to the "subject" in the key or the "subject" in the value? I think if we change the "subject" in the "by_subject" record key to a charlist instead of a binary, it would also achieve this goal. Currently, it is a binary.

what we really need is something like this:

 {:by_prefix, [70, 111, 111, 46, 66, 97, 114 | :_], :module, :definition,
 "1.15.7", "25.3.2.7"}

no matter is by_prefix or by_subject

end

describe "rename struct" do
test "succeeds when the cursor on the definition" do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
test "succeeds when the cursor on the definition" do
test "succeeds when the cursor is before the definition" do

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it though?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we hover, before the first letter of the definition, it returns the module. So, it is reasonable here. In this case, I think using "at" instead of "before" would be more appropriate.

end
] |> rename("Renamed")

refute result =~ ~S[defmodule TopLevel.Renamed.Another]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would definitely expect the module Toplevel.Module.Another to be renamed to Toplevel.Renamed.Another

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, I would like to preserve the functionality of renaming an exact module.

Consider the following scenario: Let's say we have two modules, Project.Schema.User and Project.Schema. If we find that Project.Schema is not clear in its meaning and rename it to Project.EctoHelper, should we also rename Project.Schema.User to Project.EctoHelper.User?

I believe the answer is no. Clearly, there are times when we want to rename a specific module, and there are times when we want to rename all modules that have that module as a prefix.

@scottming scottming force-pushed the rename-module branch 2 times, most recently from 143d52b to c6047d3 Compare December 17, 2023 02:57
@scottming scottming force-pushed the rename-module branch 4 times, most recently from f0586d8 to 8849f77 Compare December 31, 2023 06:44
@scottming
Copy link
Collaborator Author

@scohen I have applied almost all of your suggestions. Please take the time to review this PR again, especially the two commits related to the schema.

@scottming
Copy link
Collaborator Author

It can only simplify part of things, but I think I can split this PR into multiple PRs.

@scottming scottming closed this Feb 16, 2024
scottming added a commit that referenced this pull request Mar 17, 2024
…mplementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.
scottming added a commit to scottming/lexical that referenced this pull request Mar 17, 2024
… previous implementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.
scottming added a commit that referenced this pull request Mar 19, 2024
…mplementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.
scottming added a commit that referenced this pull request Mar 19, 2024
…mplementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.
scottming added a commit that referenced this pull request Mar 20, 2024
…mplementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.
scottming added a commit that referenced this pull request Mar 27, 2024
…mplementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.
scottming added a commit that referenced this pull request Mar 28, 2024
…mplementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.
scottming added a commit that referenced this pull request Mar 29, 2024
…mplementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.
scottming added a commit that referenced this pull request Apr 2, 2024
…mplementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.
scottming added a commit that referenced this pull request Apr 4, 2024
…mplementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.
scottming added a commit that referenced this pull request Apr 6, 2024
Enhanced the application by integrating rename functionality, increasing its editing capabilities. This includes supporting the preparation and execution of rename operations in various modules such as the lexical AST module, protocol request and response modules, remote control API, and server provider handling. Key additions entail aliasing for easier reference, handling new rename-related requests and responses, and implementing server state updates to acknowledge rename capabilities. The changes underscore our dedication to improving the tool's utility and ensuring a more dynamic and responsive user experience in code manipulation scenarios.

Filter out the `:struct` type references

Add some handler tests for `rename`

Add doc for `local_module_name`

Move `rename` from `code_intelligence` to `code_mod`

Move the prepare logic to a individual module

This PR is primarily copied from #374, but compared to the previous implementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.

Surround the whole module when renaming happens

Remove logic related to the rename function.

Apply some code review suggestions
scottming added a commit that referenced this pull request Apr 13, 2024
Enhanced the application by integrating rename functionality, increasing its editing capabilities. This includes supporting the preparation and execution of rename operations in various modules such as the lexical AST module, protocol request and response modules, remote control API, and server provider handling. Key additions entail aliasing for easier reference, handling new rename-related requests and responses, and implementing server state updates to acknowledge rename capabilities. The changes underscore our dedication to improving the tool's utility and ensuring a more dynamic and responsive user experience in code manipulation scenarios.

Filter out the `:struct` type references

Add some handler tests for `rename`

Add doc for `local_module_name`

Move `rename` from `code_intelligence` to `code_mod`

Move the prepare logic to a individual module

This PR is primarily copied from #374, but compared to the previous implementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.

Surround the whole module when renaming happens

Remove logic related to the rename function.

Apply some code review suggestions
scottming added a commit that referenced this pull request Apr 20, 2024
Enhanced the application by integrating rename functionality, increasing its editing capabilities. This includes supporting the preparation and execution of rename operations in various modules such as the lexical AST module, protocol request and response modules, remote control API, and server provider handling. Key additions entail aliasing for easier reference, handling new rename-related requests and responses, and implementing server state updates to acknowledge rename capabilities. The changes underscore our dedication to improving the tool's utility and ensuring a more dynamic and responsive user experience in code manipulation scenarios.

Filter out the `:struct` type references

Add some handler tests for `rename`

Add doc for `local_module_name`

Move `rename` from `code_intelligence` to `code_mod`

Move the prepare logic to a individual module

This PR is primarily copied from #374, but compared to the previous implementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.

Surround the whole module when renaming happens

Remove logic related to the rename function.

Apply some code review suggestions
scottming added a commit that referenced this pull request Apr 26, 2024
Enhanced the application by integrating rename functionality, increasing its editing capabilities. This includes supporting the preparation and execution of rename operations in various modules such as the lexical AST module, protocol request and response modules, remote control API, and server provider handling. Key additions entail aliasing for easier reference, handling new rename-related requests and responses, and implementing server state updates to acknowledge rename capabilities. The changes underscore our dedication to improving the tool's utility and ensuring a more dynamic and responsive user experience in code manipulation scenarios.

Filter out the `:struct` type references

Add some handler tests for `rename`

Add doc for `local_module_name`

Move `rename` from `code_intelligence` to `code_mod`

Move the prepare logic to a individual module

This PR is primarily copied from #374, but compared to the previous implementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.

Surround the whole module when renaming happens

Remove logic related to the rename function.

Apply some code review suggestions

Fix a bug when expanding the module

Fix a merge error

Apply a format module usage suggestion

Update apps/remote_control/lib/lexical/remote_control/code_mod/rename.ex

Co-authored-by: Steve Cohen <[email protected]>

Apply the `defdelegate` suggestion

Fix a bug when the descendant containing the old suffix
scottming added a commit that referenced this pull request Apr 26, 2024
Enhanced the application by integrating rename functionality, increasing its editing capabilities. This includes supporting the preparation and execution of rename operations in various modules such as the lexical AST module, protocol request and response modules, remote control API, and server provider handling. Key additions entail aliasing for easier reference, handling new rename-related requests and responses, and implementing server state updates to acknowledge rename capabilities. The changes underscore our dedication to improving the tool's utility and ensuring a more dynamic and responsive user experience in code manipulation scenarios.

Filter out the `:struct` type references

Add some handler tests for `rename`

Add doc for `local_module_name`

Move `rename` from `code_intelligence` to `code_mod`

Move the prepare logic to a individual module

This PR is primarily copied from #374, but compared to the previous implementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.

Surround the whole module when renaming happens

Remove logic related to the rename function.

Apply some code review suggestions

Fix a bug when expanding the module

Fix a merge error

Apply a format module usage suggestion

Update apps/remote_control/lib/lexical/remote_control/code_mod/rename.ex

Co-authored-by: Steve Cohen <[email protected]>

Apply the `defdelegate` suggestion

Fix a bug when the descendant containing the old suffix
scottming added a commit that referenced this pull request May 4, 2024
Enhanced the application by integrating rename functionality, increasing its editing capabilities. This includes supporting the preparation and execution of rename operations in various modules such as the lexical AST module, protocol request and response modules, remote control API, and server provider handling. Key additions entail aliasing for easier reference, handling new rename-related requests and responses, and implementing server state updates to acknowledge rename capabilities. The changes underscore our dedication to improving the tool's utility and ensuring a more dynamic and responsive user experience in code manipulation scenarios.

Filter out the `:struct` type references

Add some handler tests for `rename`

Add doc for `local_module_name`

Move `rename` from `code_intelligence` to `code_mod`

Move the prepare logic to a individual module

This PR is primarily copied from #374, but compared to the previous implementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.

Surround the whole module when renaming happens

Remove logic related to the rename function.

Apply some code review suggestions

Fix a bug when expanding the module

Fix a merge error

Apply a format module usage suggestion

Update apps/remote_control/lib/lexical/remote_control/code_mod/rename.ex

Co-authored-by: Steve Cohen <[email protected]>

Apply the `defdelegate` suggestion

Fix a bug when the descendant containing the old suffix
scottming added a commit that referenced this pull request May 12, 2024
Enhanced the application by integrating rename functionality, increasing its editing capabilities. This includes supporting the preparation and execution of rename operations in various modules such as the lexical AST module, protocol request and response modules, remote control API, and server provider handling. Key additions entail aliasing for easier reference, handling new rename-related requests and responses, and implementing server state updates to acknowledge rename capabilities. The changes underscore our dedication to improving the tool's utility and ensuring a more dynamic and responsive user experience in code manipulation scenarios.

Filter out the `:struct` type references

Add some handler tests for `rename`

Add doc for `local_module_name`

Move `rename` from `code_intelligence` to `code_mod`

Move the prepare logic to a individual module

This PR is primarily copied from #374, but compared to the previous implementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.

Surround the whole module when renaming happens

Remove logic related to the rename function.

Apply some code review suggestions

Fix a bug when expanding the module

Fix a merge error

Apply a format module usage suggestion

Update apps/remote_control/lib/lexical/remote_control/code_mod/rename.ex

Co-authored-by: Steve Cohen <[email protected]>

Apply the `defdelegate` suggestion

Fix a bug when the descendant containing the old suffix
scottming added a commit that referenced this pull request May 24, 2024
Enhanced the application by integrating rename functionality, increasing its editing capabilities. This includes supporting the preparation and execution of rename operations in various modules such as the lexical AST module, protocol request and response modules, remote control API, and server provider handling. Key additions entail aliasing for easier reference, handling new rename-related requests and responses, and implementing server state updates to acknowledge rename capabilities. The changes underscore our dedication to improving the tool's utility and ensuring a more dynamic and responsive user experience in code manipulation scenarios.

Filter out the `:struct` type references

Add some handler tests for `rename`

Add doc for `local_module_name`

Move `rename` from `code_intelligence` to `code_mod`

Move the prepare logic to a individual module

This PR is primarily copied from #374, but compared to the previous implementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.

Surround the whole module when renaming happens

Remove logic related to the rename function.

Apply some code review suggestions

Fix a bug when expanding the module

Fix a merge error

Apply a format module usage suggestion

Update apps/remote_control/lib/lexical/remote_control/code_mod/rename.ex

Co-authored-by: Steve Cohen <[email protected]>

Apply the `defdelegate` suggestion

Fix a bug when the descendant containing the old suffix
scottming added a commit that referenced this pull request May 24, 2024
Enhanced the application by integrating rename functionality, increasing its editing capabilities. This includes supporting the preparation and execution of rename operations in various modules such as the lexical AST module, protocol request and response modules, remote control API, and server provider handling. Key additions entail aliasing for easier reference, handling new rename-related requests and responses, and implementing server state updates to acknowledge rename capabilities. The changes underscore our dedication to improving the tool's utility and ensuring a more dynamic and responsive user experience in code manipulation scenarios.

Filter out the `:struct` type references

Add some handler tests for `rename`

Add doc for `local_module_name`

Move `rename` from `code_intelligence` to `code_mod`

Move the prepare logic to a individual module

This PR is primarily copied from #374, but compared to the previous implementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.

Surround the whole module when renaming happens

Remove logic related to the rename function.

Apply some code review suggestions

Fix a bug when expanding the module

Fix a merge error

Apply a format module usage suggestion

Update apps/remote_control/lib/lexical/remote_control/code_mod/rename.ex

Co-authored-by: Steve Cohen <[email protected]>

Apply the `defdelegate` suggestion

Fix a bug when the descendant containing the old suffix
scottming added a commit that referenced this pull request May 25, 2024
Enhanced the application by integrating rename functionality, increasing its editing capabilities. This includes supporting the preparation and execution of rename operations in various modules such as the lexical AST module, protocol request and response modules, remote control API, and server provider handling. Key additions entail aliasing for easier reference, handling new rename-related requests and responses, and implementing server state updates to acknowledge rename capabilities. The changes underscore our dedication to improving the tool's utility and ensuring a more dynamic and responsive user experience in code manipulation scenarios.

Filter out the `:struct` type references

Add some handler tests for `rename`

Add doc for `local_module_name`

Move `rename` from `code_intelligence` to `code_mod`

Move the prepare logic to a individual module

This PR is primarily copied from #374, but compared to the previous implementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.

Surround the whole module when renaming happens

Remove logic related to the rename function.

Apply some code review suggestions

Fix a bug when expanding the module

Fix a merge error

Apply a format module usage suggestion

Update apps/remote_control/lib/lexical/remote_control/code_mod/rename.ex

Co-authored-by: Steve Cohen <[email protected]>

Apply the `defdelegate` suggestion

Fix a bug when the descendant containing the old suffix
scottming added a commit to scottming/lexical that referenced this pull request May 31, 2024
Enhanced the application by integrating rename functionality, increasing its editing capabilities. This includes supporting the preparation and execution of rename operations in various modules such as the lexical AST module, protocol request and response modules, remote control API, and server provider handling. Key additions entail aliasing for easier reference, handling new rename-related requests and responses, and implementing server state updates to acknowledge rename capabilities. The changes underscore our dedication to improving the tool's utility and ensuring a more dynamic and responsive user experience in code manipulation scenarios.

Filter out the `:struct` type references

Add some handler tests for `rename`

Add doc for `local_module_name`

Move `rename` from `code_intelligence` to `code_mod`

Move the prepare logic to a individual module

This PR is primarily copied from lexical-lsp#374, but compared to the previous implementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.

Surround the whole module when renaming happens

Remove logic related to the rename function.

Apply some code review suggestions

Fix a bug when expanding the module

Fix a merge error

Apply a format module usage suggestion

Update apps/remote_control/lib/lexical/remote_control/code_mod/rename.ex

Co-authored-by: Steve Cohen <[email protected]>

Apply the `defdelegate` suggestion

Fix a bug when the descendant containing the old suffix
scottming added a commit that referenced this pull request Jun 1, 2024
Enhanced the application by integrating rename functionality, increasing its editing capabilities. This includes supporting the preparation and execution of rename operations in various modules such as the lexical AST module, protocol request and response modules, remote control API, and server provider handling. Key additions entail aliasing for easier reference, handling new rename-related requests and responses, and implementing server state updates to acknowledge rename capabilities. The changes underscore our dedication to improving the tool's utility and ensuring a more dynamic and responsive user experience in code manipulation scenarios.

Filter out the `:struct` type references

Add some handler tests for `rename`

Add doc for `local_module_name`

Move `rename` from `code_intelligence` to `code_mod`

Move the prepare logic to a individual module

This PR is primarily copied from #374, but compared to the previous implementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.

Surround the whole module when renaming happens

Remove logic related to the rename function.

Apply some code review suggestions

Fix a bug when expanding the module

Fix a merge error

Apply a format module usage suggestion

Update apps/remote_control/lib/lexical/remote_control/code_mod/rename.ex

Co-authored-by: Steve Cohen <[email protected]>

Apply the `defdelegate` suggestion

Fix a bug when the descendant containing the old suffix
scottming added a commit to scottming/lexical that referenced this pull request Jun 1, 2024
Enhanced the application by integrating rename functionality, increasing its editing capabilities. This includes supporting the preparation and execution of rename operations in various modules such as the lexical AST module, protocol request and response modules, remote control API, and server provider handling. Key additions entail aliasing for easier reference, handling new rename-related requests and responses, and implementing server state updates to acknowledge rename capabilities. The changes underscore our dedication to improving the tool's utility and ensuring a more dynamic and responsive user experience in code manipulation scenarios.

Filter out the `:struct` type references

Add some handler tests for `rename`

Add doc for `local_module_name`

Move `rename` from `code_intelligence` to `code_mod`

Move the prepare logic to a individual module

This PR is primarily copied from lexical-lsp#374, but compared to the previous implementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.

Surround the whole module when renaming happens

Remove logic related to the rename function.

Apply some code review suggestions

Fix a bug when expanding the module

Fix a merge error

Apply a format module usage suggestion

Update apps/remote_control/lib/lexical/remote_control/code_mod/rename.ex

Co-authored-by: Steve Cohen <[email protected]>

Apply the `defdelegate` suggestion

Fix a bug when the descendant containing the old suffix
scottming added a commit to scottming/lexical that referenced this pull request Jul 4, 2024
Enhanced the application by integrating rename functionality, increasing its editing capabilities. This includes supporting the preparation and execution of rename operations in various modules such as the lexical AST module, protocol request and response modules, remote control API, and server provider handling. Key additions entail aliasing for easier reference, handling new rename-related requests and responses, and implementing server state updates to acknowledge rename capabilities. The changes underscore our dedication to improving the tool's utility and ensuring a more dynamic and responsive user experience in code manipulation scenarios.

Filter out the `:struct` type references

Add some handler tests for `rename`

Add doc for `local_module_name`

Move `rename` from `code_intelligence` to `code_mod`

Move the prepare logic to a individual module

This PR is primarily copied from lexical-lsp#374, but compared to the previous implementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.

Surround the whole module when renaming happens

Remove logic related to the rename function.

Apply some code review suggestions

Fix a bug when expanding the module

Fix a merge error

Apply a format module usage suggestion

Update apps/remote_control/lib/lexical/remote_control/code_mod/rename.ex

Co-authored-by: Steve Cohen <[email protected]>

Apply the `defdelegate` suggestion

Fix a bug when the descendant containing the old suffix
scottming added a commit to scottming/lexical that referenced this pull request Jul 12, 2024
Enhanced the application by integrating rename functionality, increasing its editing capabilities. This includes supporting the preparation and execution of rename operations in various modules such as the lexical AST module, protocol request and response modules, remote control API, and server provider handling. Key additions entail aliasing for easier reference, handling new rename-related requests and responses, and implementing server state updates to acknowledge rename capabilities. The changes underscore our dedication to improving the tool's utility and ensuring a more dynamic and responsive user experience in code manipulation scenarios.

Filter out the `:struct` type references

Add some handler tests for `rename`

Add doc for `local_module_name`

Move `rename` from `code_intelligence` to `code_mod`

Move the prepare logic to a individual module

This PR is primarily copied from lexical-lsp#374, but compared to the previous implementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.

Surround the whole module when renaming happens

Remove logic related to the rename function.

Apply some code review suggestions

Fix a bug when expanding the module

Fix a merge error

Apply a format module usage suggestion

Update apps/remote_control/lib/lexical/remote_control/code_mod/rename.ex

Co-authored-by: Steve Cohen <[email protected]>

Apply the `defdelegate` suggestion

Fix a bug when the descendant containing the old suffix
scottming added a commit to scottming/lexical that referenced this pull request Jul 12, 2024
Enhanced the application by integrating rename functionality, increasing its editing capabilities. This includes supporting the preparation and execution of rename operations in various modules such as the lexical AST module, protocol request and response modules, remote control API, and server provider handling. Key additions entail aliasing for easier reference, handling new rename-related requests and responses, and implementing server state updates to acknowledge rename capabilities. The changes underscore our dedication to improving the tool's utility and ensuring a more dynamic and responsive user experience in code manipulation scenarios.

Filter out the `:struct` type references

Add some handler tests for `rename`

Add doc for `local_module_name`

Move `rename` from `code_intelligence` to `code_mod`

Move the prepare logic to a individual module

This PR is primarily copied from lexical-lsp#374, but compared to the previous implementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.

Surround the whole module when renaming happens

Remove logic related to the rename function.

Apply some code review suggestions

Fix a bug when expanding the module

Fix a merge error

Apply a format module usage suggestion

Update apps/remote_control/lib/lexical/remote_control/code_mod/rename.ex

Co-authored-by: Steve Cohen <[email protected]>

Apply the `defdelegate` suggestion

Fix a bug when the descendant containing the old suffix
scottming added a commit that referenced this pull request Sep 6, 2024
Enhanced the application by integrating rename functionality, increasing its editing capabilities. This includes supporting the preparation and execution of rename operations in various modules such as the lexical AST module, protocol request and response modules, remote control API, and server provider handling. Key additions entail aliasing for easier reference, handling new rename-related requests and responses, and implementing server state updates to acknowledge rename capabilities. The changes underscore our dedication to improving the tool's utility and ensuring a more dynamic and responsive user experience in code manipulation scenarios.

Filter out the `:struct` type references

Add some handler tests for `rename`

Add doc for `local_module_name`

Move `rename` from `code_intelligence` to `code_mod`

Move the prepare logic to a individual module

This PR is primarily copied from #374, but compared to the previous implementation, we have made two changes:

1. We constrained the scope of renaming, meaning that renaming a module is only allowed at its definition. This simplification reduces a lot of computations.
2. Based on the first point, our preparation no longer returns just a single local module, but instead, the entire module. This means that module renaming has become more powerful. We can not only rename a single local module but also simplify a module. For example, renaming TopLevel.Parent.Child to TopLevel.Child, or renaming some middle parts, like TopLevel.Parent.Child to TopLevel.Renamed.

I personally really like this change, especially the second point, which makes module renaming much more practical.

Surround the whole module when renaming happens

Remove logic related to the rename function.

Apply some code review suggestions

Fix a bug when expanding the module

Fix a merge error

Apply a format module usage suggestion

Update apps/remote_control/lib/lexical/remote_control/code_mod/rename.ex

Co-authored-by: Steve Cohen <[email protected]>

Apply the `defdelegate` suggestion

Fix a bug when the descendant containing the old suffix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants