forked from VimPlug/jedi
renaming works now a little bit better with modules
This commit is contained in:
@@ -339,7 +339,8 @@ class Script(object):
|
|||||||
This function can be used either to show all the usages of a variable
|
This function can be used either to show all the usages of a variable
|
||||||
or for renaming purposes.
|
or for renaming purposes.
|
||||||
"""
|
"""
|
||||||
definitions, search_name = self._goto(check_imports=False)
|
definitions, search_name = self._goto(check_imports=True)
|
||||||
|
definitions = dynamic.related_name_add_import_modules(definitions)
|
||||||
|
|
||||||
module = set([d.get_parent_until() for d in definitions])
|
module = set([d.get_parent_until() for d in definitions])
|
||||||
module.add(self.parser.module)
|
module.add(self.parser.module)
|
||||||
@@ -372,6 +373,8 @@ class Script(object):
|
|||||||
names.append(dynamic.RelatedName(n, d))
|
names.append(dynamic.RelatedName(n, d))
|
||||||
elif isinstance(d, parsing.Name):
|
elif isinstance(d, parsing.Name):
|
||||||
names.append(dynamic.RelatedName(d.names[0], d))
|
names.append(dynamic.RelatedName(d.names[0], d))
|
||||||
|
elif isinstance(d, parsing.Module):
|
||||||
|
names.append(dynamic.RelatedName(d.get_names(), d))
|
||||||
else:
|
else:
|
||||||
names.append(dynamic.RelatedName(d.name.names[0], d))
|
names.append(dynamic.RelatedName(d.name.names[0], d))
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import helpers
|
|||||||
import settings
|
import settings
|
||||||
import debug
|
import debug
|
||||||
import builtin
|
import builtin
|
||||||
|
import imports
|
||||||
|
|
||||||
# This is something like the sys.path, but only for searching params. It means
|
# This is something like the sys.path, but only for searching params. It means
|
||||||
# that this is the order in which Jedi searches params.
|
# that this is the order in which Jedi searches params.
|
||||||
@@ -347,7 +348,9 @@ def related_names(definitions, search_name, mods):
|
|||||||
|
|
||||||
for f in follow:
|
for f in follow:
|
||||||
follow_res, search = evaluate.goto(call.parent_stmt(), f)
|
follow_res, search = evaluate.goto(call.parent_stmt(), f)
|
||||||
|
follow_res = related_name_add_import_modules(follow_res)
|
||||||
|
|
||||||
|
#print follow_res, [d.parent() for d in follow_res]
|
||||||
# compare to see if they match
|
# compare to see if they match
|
||||||
if True in [r in definitions for r in follow_res]:
|
if True in [r in definitions for r in follow_res]:
|
||||||
scope = call.parent_stmt()
|
scope = call.parent_stmt()
|
||||||
@@ -366,10 +369,25 @@ def related_names(definitions, search_name, mods):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
continue
|
continue
|
||||||
for stmt in stmts:
|
for stmt in stmts:
|
||||||
|
print stmt
|
||||||
for call in _scan_array(stmt.get_assignment_calls(), search_name):
|
for call in _scan_array(stmt.get_assignment_calls(), search_name):
|
||||||
names += check_call(call)
|
names += check_call(call)
|
||||||
return names
|
return names
|
||||||
|
|
||||||
|
def related_name_add_import_modules(definitions):
|
||||||
|
""" Adds the modules of the imports """
|
||||||
|
new = []
|
||||||
|
for d in definitions:
|
||||||
|
if isinstance(d.parent(), parsing.Import):
|
||||||
|
# introduce kill_count for not fully used imports
|
||||||
|
s = imports.ImportPath(d.parent(), False, direct_resolve=True)
|
||||||
|
try:
|
||||||
|
new.append(s.follow(is_goto=True)[0])
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
return definitions + new
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class BaseOutput(object):
|
class BaseOutput(object):
|
||||||
def __init__(self, start_pos, definition):
|
def __init__(self, start_pos, definition):
|
||||||
|
|||||||
Reference in New Issue
Block a user