mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-13 10:16:00 +00:00
JBRename: add options for renaming in comments and text occurrences, defaults to True
This commit is contained in:
1 parent
8a6b45bd9f
commit
f30b3cc1e8
2 files changed
+24
-4
No files matched your search
+5
-2
@@ -2,8 +2,11 @@
|
||||
|
||||
Status of the `main` branch. Changes prior to the next official version change will appear here.
|
||||
|
||||
* JetBrains:
|
||||
- `JetBrainsRenameTool` can now also rename occurrences in comments and text.
|
||||
|
||||
* Language Servers:
|
||||
- Fix Dart LSP returning only symbol name as body instead of full method body
|
||||
- Fix Dart LSP returning only symbol name as body instead of full method body.
|
||||
|
||||
# 1.1.0
|
||||
|
||||
@@ -287,4 +290,4 @@ Fixes:
|
||||
|
||||
# 2025-04-01
|
||||
|
||||
Initial public version
|
||||
Initial public version
|
||||
@@ -512,16 +512,33 @@ class JetBrainsRenameTool(Tool, ToolMarkerSymbolicEdit, ToolMarkerOptional):
|
||||
Renames a symbol, file or directory throughout the codebase using the JetBrains backend.
|
||||
"""
|
||||
|
||||
def apply(self, relative_path: str, new_name: str, name_path: str | None = None) -> str:
|
||||
def apply(
|
||||
self,
|
||||
relative_path: str,
|
||||
new_name: str,
|
||||
name_path: str | None = None,
|
||||
rename_in_comments: bool = False,
|
||||
rename_in_text_occurrences: bool = False,
|
||||
) -> str:
|
||||
"""
|
||||
Renames a symbol, file or directory throughout the codebase.
|
||||
Note: renaming in comments/text is on a best-effort basis by the IDE; if the symbol name is non-unique, further
|
||||
verification is recommended.
|
||||
|
||||
:param relative_path: if `name_path` is passed, the relative path of the file containing the symbol.
|
||||
Otherwise, the path to the directory or file to rename.
|
||||
:param new_name: the new name
|
||||
:param name_path: the name path of the symbol to rename or None if renaming a file or directory.
|
||||
:param rename_in_comments: whether to also rename occurrences in comments. Default True.
|
||||
:param rename_in_text_occurrences: whether to also rename occurrences in text. Default True.
|
||||
:return: a status message
|
||||
"""
|
||||
code_editor = JetBrainsCodeEditor(self.project)
|
||||
result = code_editor.rename_symbol(name_path=name_path, relative_path=relative_path, new_name=new_name)
|
||||
result = code_editor.rename_symbol(
|
||||
name_path=name_path,
|
||||
relative_path=relative_path,
|
||||
new_name=new_name,
|
||||
rename_in_comments=rename_in_comments,
|
||||
rename_in_text_occurrences=rename_in_text_occurrences,
|
||||
)
|
||||
return self._to_json(result)
|
||||
Reference in new issue
Block a user