Make sure to have a rename test if no name is under the cursor

This commit is contained in:
Dave Halter
2020-02-14 14:24:05 +01:00
parent dbf88f2750
commit 14180ad185
2 changed files with 9 additions and 1 deletions

View File

@@ -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):

View File

@@ -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'}