forked from VimPlug/jedi
removal of old unused goto stuff
This commit is contained in:
36
jedi/api.py
36
jedi/api.py
@@ -299,17 +299,8 @@ class Script(object):
|
||||
return sorted(d, key=lambda x: (x.module_path, x.start_pos))
|
||||
|
||||
def goto(self):
|
||||
goto_path = self.module.get_path_under_cursor()
|
||||
goto_path, dot, search_name = self._get_completion_parts(goto_path)
|
||||
|
||||
# define goto path the right way
|
||||
if not dot:
|
||||
goto_path = search_name
|
||||
search_name_new = None
|
||||
else:
|
||||
search_name_new = search_name
|
||||
|
||||
user_stmt = self.parser.user_stmt
|
||||
goto_path = self.module.get_path_under_cursor()
|
||||
context = self.module.get_context()
|
||||
if next(context) in ('class', 'def'):
|
||||
definitions = set([self.module.parser.user_scope])
|
||||
@@ -329,11 +320,8 @@ class Script(object):
|
||||
except IndexError:
|
||||
definitions = []
|
||||
else:
|
||||
goto_path = self.module.get_path_under_cursor()
|
||||
stmt = self._get_under_cursor_stmt(goto_path)
|
||||
definitions, search_name = evaluate.goto3(stmt)
|
||||
#scopes = self._prepare_goto(goto_path)
|
||||
#definitions = evaluate.goto(scopes, search_name_new)
|
||||
definitions, search_name = evaluate.goto(stmt)
|
||||
|
||||
d = [Definition(d) for d in set(definitions)]
|
||||
return sorted(d, key=lambda x: (x.module_path, x.start_pos))
|
||||
@@ -346,15 +334,6 @@ class Script(object):
|
||||
or for renaming purposes.
|
||||
"""
|
||||
goto_path = self.module.get_path_under_cursor()
|
||||
goto_path, dot, search_name = self._get_completion_parts(goto_path)
|
||||
|
||||
# define goto path the right way
|
||||
if not dot:
|
||||
goto_path = search_name
|
||||
search_name_new = None
|
||||
else:
|
||||
search_name_new = search_name
|
||||
|
||||
context = self.module.get_context()
|
||||
if next(context) in ('class', 'def'):
|
||||
if isinstance(self.module.parser.user_scope, parsing.Function):
|
||||
@@ -362,17 +341,10 @@ class Script(object):
|
||||
else:
|
||||
e = evaluate.Class(self.module.parser.user_scope)
|
||||
definitions = [e.name]
|
||||
#elif isinstance(self.module.parser.user_stmt,
|
||||
#(parsing.Param, parsing.Import)):
|
||||
#definitions = [self.module.parser.user_stmt]
|
||||
search_name = str(e.name)
|
||||
else:
|
||||
goto_path = self.module.get_path_under_cursor()
|
||||
stmt = self._get_under_cursor_stmt(goto_path)
|
||||
definitions, search_name = evaluate.goto3(stmt)
|
||||
#print 'd', definitions, call, call.parent_stmt().parent().start_pos
|
||||
#evaluate.goto_names = []
|
||||
#scopes = self._prepare_goto(goto_path)
|
||||
#definitions = evaluate.goto2(scopes, search_name_new)
|
||||
definitions, search_name = evaluate.goto(stmt)
|
||||
|
||||
module = set([d.get_parent_until() for d in definitions])
|
||||
module.add(self.module.parser.module)
|
||||
|
||||
@@ -346,11 +346,7 @@ def related_names(definitions, search_name, mods):
|
||||
follow.append(call_path[:i + 1])
|
||||
|
||||
for f in follow:
|
||||
#print 's', evaluate.goto_names, scopes, search.start_pos
|
||||
#follow_res = evaluate.goto(scopes, search, statement_path_offset=0,
|
||||
# follow_import=True)
|
||||
#follow_res = evaluate.goto2(scopes, search)
|
||||
follow_res, search = evaluate.goto3(call.parent_stmt(), f)
|
||||
follow_res, search = evaluate.goto(call.parent_stmt(), f)
|
||||
|
||||
# compare to see if they match
|
||||
if True in [r in definitions for r in follow_res]:
|
||||
@@ -369,7 +365,6 @@ def related_names(definitions, search_name, mods):
|
||||
stmts = m.used_names[search_name]
|
||||
except KeyError:
|
||||
continue
|
||||
#TODO check heritage of statements
|
||||
for stmt in stmts:
|
||||
for call in _scan_array(stmt.get_assignment_calls(), search_name):
|
||||
names += check_call(call)
|
||||
|
||||
@@ -1513,7 +1513,7 @@ def follow_path(path, scope, position=None):
|
||||
return follow_paths(path, set(result), position=position)
|
||||
|
||||
|
||||
def goto3(stmt, call_path=None):
|
||||
def goto(stmt, call_path=None):
|
||||
if call_path is None:
|
||||
arr = stmt.get_assignment_calls()
|
||||
call = arr.get_only_subelement()
|
||||
@@ -1521,9 +1521,6 @@ def goto3(stmt, call_path=None):
|
||||
|
||||
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]
|
||||
if call_path:
|
||||
scopes = follow_call_path(iter(call_path), scope, pos)
|
||||
@@ -1536,65 +1533,4 @@ def goto3_dini_mueter(call_path, scope, pos):
|
||||
for s in scopes:
|
||||
follow_res += get_scopes_for_name(s, search, pos,
|
||||
search_global=search_global, is_goto=True)
|
||||
#print 'c', stmt, scope, follow_res
|
||||
return follow_res, search
|
||||
|
||||
|
||||
|
||||
def goto2(scopes, search_name=None):
|
||||
global goto_names
|
||||
result = goto_names
|
||||
if result == []:
|
||||
print 'LALA', scopes
|
||||
goto_names = None
|
||||
return result
|
||||
|
||||
def goto(scopes, search_name=None, statement_path_offset=1,
|
||||
follow_import=False):
|
||||
def follow_imports(names):
|
||||
global statement_path
|
||||
new = []
|
||||
for n in names:
|
||||
if isinstance(n, parsing.Import):
|
||||
statement_path = []
|
||||
scopes = imports.strip_imports([n])
|
||||
new += goto(scopes, follow_import=True)
|
||||
else:
|
||||
new.append(n)
|
||||
return new
|
||||
|
||||
if search_name is None:
|
||||
try:
|
||||
definitions = [statement_path[statement_path_offset]]
|
||||
except IndexError:
|
||||
definitions = []
|
||||
for s in scopes:
|
||||
if isinstance(s, imports.ImportPath):
|
||||
try:
|
||||
s = s.follow()[0]
|
||||
except IndexError:
|
||||
continue
|
||||
else:
|
||||
if not isinstance(s, parsing.Module):
|
||||
s = statement_path[0]
|
||||
definitions.append(s)
|
||||
else:
|
||||
names = []
|
||||
for s in scopes:
|
||||
if isinstance(s, imports.ImportPath):
|
||||
modules = s.follow()
|
||||
if modules:
|
||||
names.append(modules[0].get_module_name())
|
||||
else:
|
||||
names += s.get_defined_names()
|
||||
definitions = [n for n in names if n.names[-1] == search_name]
|
||||
|
||||
#if follow_import:
|
||||
# definitions = follow_imports(definitions)
|
||||
|
||||
definitions = set(definitions)
|
||||
#for d in definitions.copy():
|
||||
#if d.isinstance(Function, Class):
|
||||
# definitions.add(d.name)
|
||||
# definitions.remove(d)
|
||||
return definitions
|
||||
|
||||
@@ -147,8 +147,6 @@ class ImportPath(object):
|
||||
scopes = []
|
||||
elif rest:
|
||||
if is_goto:
|
||||
#scopes = list(evaluate.follow_path(iter(rest), scope))
|
||||
#scopes = evaluate.goto3_dini_mueter(rest)
|
||||
scopes = itertools.chain.from_iterable(
|
||||
evaluate.get_scopes_for_name(s, rest[0], is_goto=True)
|
||||
for s in scopes)
|
||||
|
||||
Reference in New Issue
Block a user