mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Make sure to have a rename test if no name is under the cursor
This commit is contained in:
@@ -114,6 +114,9 @@ def rename(grammar, definitions, new_name):
|
||||
file_renames = set()
|
||||
file_tree_name_map = {}
|
||||
|
||||
if not definitions:
|
||||
raise RefactoringError("There is no name under the cursor")
|
||||
|
||||
for d in definitions:
|
||||
tree_name = d._name.tree_name
|
||||
if d.type == 'module' and tree_name is None:
|
||||
@@ -129,7 +132,7 @@ def rename(grammar, definitions, new_name):
|
||||
|
||||
def inline(grammar, names):
|
||||
if not names:
|
||||
raise RefactoringError("There's no name under the cursor")
|
||||
raise RefactoringError("There is no name under the cursor")
|
||||
if any(n.api_type == 'module' for n in names):
|
||||
raise RefactoringError("Cannot inline imports or modules.")
|
||||
if any(n.tree_name is None for n in names):
|
||||
|
||||
@@ -3,6 +3,11 @@ Test coverage for renaming is mostly being done by testing
|
||||
`Script.get_references`.
|
||||
"""
|
||||
|
||||
# -------------------------------------------------- no-name
|
||||
#? 0 error {'new_name': 'blabla'}
|
||||
1
|
||||
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
There is no name under the cursor
|
||||
# -------------------------------------------------- simple
|
||||
def test1():
|
||||
#? 7 {'new_name': 'blabla'}
|
||||
|
||||
Reference in New Issue
Block a user