forked from VimPlug/jedi
renaming and goto work now +/-
This commit is contained in:
@@ -331,9 +331,7 @@ class Script(object):
|
|||||||
else:
|
else:
|
||||||
goto_path = self.module.get_path_under_cursor()
|
goto_path = self.module.get_path_under_cursor()
|
||||||
stmt = self._get_under_cursor_stmt(goto_path)
|
stmt = self._get_under_cursor_stmt(goto_path)
|
||||||
arr = stmt.get_assignment_calls()
|
definitions, search_name = evaluate.goto3(stmt)
|
||||||
call = arr.get_only_subelement()
|
|
||||||
definitions, search_name = evaluate.goto3(call)
|
|
||||||
#scopes = self._prepare_goto(goto_path)
|
#scopes = self._prepare_goto(goto_path)
|
||||||
#definitions = evaluate.goto(scopes, search_name_new)
|
#definitions = evaluate.goto(scopes, search_name_new)
|
||||||
|
|
||||||
@@ -370,9 +368,7 @@ class Script(object):
|
|||||||
else:
|
else:
|
||||||
goto_path = self.module.get_path_under_cursor()
|
goto_path = self.module.get_path_under_cursor()
|
||||||
stmt = self._get_under_cursor_stmt(goto_path)
|
stmt = self._get_under_cursor_stmt(goto_path)
|
||||||
arr = stmt.get_assignment_calls()
|
definitions, search_name = evaluate.goto3(stmt)
|
||||||
call = arr.get_only_subelement()
|
|
||||||
definitions, search_name = evaluate.goto3(call)
|
|
||||||
#print 'd', definitions, call, call.parent_stmt().parent().start_pos
|
#print 'd', definitions, call, call.parent_stmt().parent().start_pos
|
||||||
#evaluate.goto_names = []
|
#evaluate.goto_names = []
|
||||||
#scopes = self._prepare_goto(goto_path)
|
#scopes = self._prepare_goto(goto_path)
|
||||||
|
|||||||
@@ -350,7 +350,7 @@ def related_names(definitions, search_name, mods):
|
|||||||
#follow_res = evaluate.goto(scopes, search, statement_path_offset=0,
|
#follow_res = evaluate.goto(scopes, search, statement_path_offset=0,
|
||||||
# follow_import=True)
|
# follow_import=True)
|
||||||
#follow_res = evaluate.goto2(scopes, search)
|
#follow_res = evaluate.goto2(scopes, search)
|
||||||
follow_res, search = evaluate.goto3(call, f)
|
follow_res, search = evaluate.goto3(call.parent_stmt(), f)
|
||||||
|
|
||||||
# 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]:
|
||||||
|
|||||||
@@ -1513,11 +1513,17 @@ def follow_path(path, scope, position=None):
|
|||||||
return follow_paths(path, set(result), position=position)
|
return follow_paths(path, set(result), position=position)
|
||||||
|
|
||||||
|
|
||||||
def goto3(call, call_path=None):
|
def goto3(stmt, call_path=None):
|
||||||
if call_path is None:
|
if call_path is None:
|
||||||
|
arr = stmt.get_assignment_calls()
|
||||||
|
call = arr.get_only_subelement()
|
||||||
call_path = list(call.generate_call_path())
|
call_path = list(call.generate_call_path())
|
||||||
scope = call.parent_stmt().parent()
|
|
||||||
pos = call.parent_stmt().start_pos
|
scope = stmt.parent()
|
||||||
|
pos = stmt.start_pos
|
||||||
|
return goto3_dini_mueter(call_path, scope, pos)
|
||||||
|
|
||||||
|
def goto3_dini_mueter(call_path, scope, pos):
|
||||||
call_path, search = call_path[:-1], call_path[-1]
|
call_path, search = call_path[:-1], call_path[-1]
|
||||||
if call_path:
|
if call_path:
|
||||||
scopes = follow_call_path(iter(call_path), scope, pos)
|
scopes = follow_call_path(iter(call_path), scope, pos)
|
||||||
@@ -1530,10 +1536,11 @@ def goto3(call, call_path=None):
|
|||||||
for s in scopes:
|
for s in scopes:
|
||||||
follow_res += get_scopes_for_name(s, search, pos,
|
follow_res += get_scopes_for_name(s, search, pos,
|
||||||
search_global=search_global, is_goto=True)
|
search_global=search_global, is_goto=True)
|
||||||
#print 'c', call, scope, follow_res
|
#print 'c', stmt, scope, follow_res
|
||||||
return follow_res, search
|
return follow_res, search
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def goto2(scopes, search_name=None):
|
def goto2(scopes, search_name=None):
|
||||||
global goto_names
|
global goto_names
|
||||||
result = goto_names
|
result = goto_names
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import modules
|
|||||||
import debug
|
import debug
|
||||||
import parsing
|
import parsing
|
||||||
import evaluate
|
import evaluate
|
||||||
|
import itertools
|
||||||
|
|
||||||
|
|
||||||
class ModuleNotFound(Exception):
|
class ModuleNotFound(Exception):
|
||||||
@@ -138,17 +139,22 @@ class ImportPath(object):
|
|||||||
debug.warning('Module not found: ' + str(self.import_stmt))
|
debug.warning('Module not found: ' + str(self.import_stmt))
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
scopes = [scope]
|
||||||
|
scopes += itertools.chain.from_iterable(
|
||||||
|
remove_star_imports(s) for s in scopes)
|
||||||
|
|
||||||
if len(rest) > 1 or rest and self.is_like_search:
|
if len(rest) > 1 or rest and self.is_like_search:
|
||||||
scopes = []
|
scopes = []
|
||||||
elif rest:
|
elif rest:
|
||||||
scopes = list(evaluate.follow_path(iter(rest), scope))
|
if is_goto:
|
||||||
else:
|
#scopes = list(evaluate.follow_path(iter(rest), scope))
|
||||||
scopes = [scope]
|
#scopes = evaluate.goto3_dini_mueter(rest)
|
||||||
|
scopes = itertools.chain.from_iterable(
|
||||||
new = []
|
evaluate.get_scopes_for_name(s, rest[0], is_goto=True)
|
||||||
for scope in scopes:
|
for s in scopes)
|
||||||
new += remove_star_imports(scope)
|
else:
|
||||||
scopes += new
|
scopes = evaluate.follow_path(iter(rest), scope)
|
||||||
|
scopes = list(scopes)
|
||||||
|
|
||||||
if self.is_nested_import():
|
if self.is_nested_import():
|
||||||
scopes.append(self.get_nested_import(scope))
|
scopes.append(self.get_nested_import(scope))
|
||||||
|
|||||||
Reference in New Issue
Block a user