1
0
forked from VimPlug/jedi

renaming and goto work now +/-

This commit is contained in:
David Halter
2012-09-22 00:15:32 +02:00
parent 32b51e0c68
commit fd760f1870
4 changed files with 28 additions and 19 deletions

View File

@@ -331,9 +331,7 @@ class Script(object):
else:
goto_path = self.module.get_path_under_cursor()
stmt = self._get_under_cursor_stmt(goto_path)
arr = stmt.get_assignment_calls()
call = arr.get_only_subelement()
definitions, search_name = evaluate.goto3(call)
definitions, search_name = evaluate.goto3(stmt)
#scopes = self._prepare_goto(goto_path)
#definitions = evaluate.goto(scopes, search_name_new)
@@ -370,9 +368,7 @@ class Script(object):
else:
goto_path = self.module.get_path_under_cursor()
stmt = self._get_under_cursor_stmt(goto_path)
arr = stmt.get_assignment_calls()
call = arr.get_only_subelement()
definitions, search_name = evaluate.goto3(call)
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)

View File

@@ -350,7 +350,7 @@ def related_names(definitions, search_name, mods):
#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, f)
follow_res, search = evaluate.goto3(call.parent_stmt(), f)
# compare to see if they match
if True in [r in definitions for r in follow_res]:

View File

@@ -1513,11 +1513,17 @@ def follow_path(path, scope, position=None):
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:
arr = stmt.get_assignment_calls()
call = arr.get_only_subelement()
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]
if call_path:
scopes = follow_call_path(iter(call_path), scope, pos)
@@ -1530,10 +1536,11 @@ def goto3(call, call_path=None):
for s in scopes:
follow_res += get_scopes_for_name(s, search, pos,
search_global=search_global, is_goto=True)
#print 'c', call, scope, follow_res
#print 'c', stmt, scope, follow_res
return follow_res, search
def goto2(scopes, search_name=None):
global goto_names
result = goto_names

View File

@@ -11,6 +11,7 @@ import modules
import debug
import parsing
import evaluate
import itertools
class ModuleNotFound(Exception):
@@ -138,17 +139,22 @@ class ImportPath(object):
debug.warning('Module not found: ' + str(self.import_stmt))
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:
scopes = []
elif rest:
scopes = list(evaluate.follow_path(iter(rest), scope))
else:
scopes = [scope]
new = []
for scope in scopes:
new += remove_star_imports(scope)
scopes += new
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)
else:
scopes = evaluate.follow_path(iter(rest), scope)
scopes = list(scopes)
if self.is_nested_import():
scopes.append(self.get_nested_import(scope))