mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +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_renames = set()
|
||||||
file_tree_name_map = {}
|
file_tree_name_map = {}
|
||||||
|
|
||||||
|
if not definitions:
|
||||||
|
raise RefactoringError("There is no name under the cursor")
|
||||||
|
|
||||||
for d in definitions:
|
for d in definitions:
|
||||||
tree_name = d._name.tree_name
|
tree_name = d._name.tree_name
|
||||||
if d.type == 'module' and tree_name is None:
|
if d.type == 'module' and tree_name is None:
|
||||||
@@ -129,7 +132,7 @@ def rename(grammar, definitions, new_name):
|
|||||||
|
|
||||||
def inline(grammar, names):
|
def inline(grammar, names):
|
||||||
if not 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):
|
if any(n.api_type == 'module' for n in names):
|
||||||
raise RefactoringError("Cannot inline imports or modules.")
|
raise RefactoringError("Cannot inline imports or modules.")
|
||||||
if any(n.tree_name is None for n in names):
|
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`.
|
`Script.get_references`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# -------------------------------------------------- no-name
|
||||||
|
#? 0 error {'new_name': 'blabla'}
|
||||||
|
1
|
||||||
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
There is no name under the cursor
|
||||||
# -------------------------------------------------- simple
|
# -------------------------------------------------- simple
|
||||||
def test1():
|
def test1():
|
||||||
#? 7 {'new_name': 'blabla'}
|
#? 7 {'new_name': 'blabla'}
|
||||||
|
|||||||
Reference in New Issue
Block a user