forked from VimPlug/jedi
renaming again, should be a little bit better. but some things are commented.
This commit is contained in:
@@ -34,7 +34,7 @@ class CachedModule(object):
|
|||||||
if not self._parser:
|
if not self._parser:
|
||||||
try:
|
try:
|
||||||
timestamp, parser = self.cache[self.path or self.name]
|
timestamp, parser = self.cache[self.path or self.name]
|
||||||
if not self.path or timestamp == os.path.getmtime(self.path):
|
if not self.path or os.path.getmtime(self.path) <= timestamp:
|
||||||
self._parser = parser
|
self._parser = parser
|
||||||
else:
|
else:
|
||||||
raise KeyError()
|
raise KeyError()
|
||||||
|
|||||||
@@ -353,7 +353,8 @@ def related_names(definitions, search_name, mods):
|
|||||||
else:
|
else:
|
||||||
search = None
|
search = None
|
||||||
scopes = evaluate.follow_call_path(iter(f), scope, position)
|
scopes = evaluate.follow_call_path(iter(f), scope, position)
|
||||||
follow_res = evaluate.goto(scopes, search, statement_path_offset=0)
|
follow_res = evaluate.goto(scopes, search, statement_path_offset=0,
|
||||||
|
follow_import=True)
|
||||||
|
|
||||||
# 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]:
|
||||||
|
|||||||
@@ -1501,7 +1501,20 @@ def follow_path(path, scope, position=None):
|
|||||||
return follow_paths(path, set(result), position=position)
|
return follow_paths(path, set(result), position=position)
|
||||||
|
|
||||||
|
|
||||||
def goto(scopes, search_name=None, statement_path_offset=1):
|
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:
|
if search_name is None:
|
||||||
try:
|
try:
|
||||||
definitions = [statement_path[statement_path_offset]]
|
definitions = [statement_path[statement_path_offset]]
|
||||||
@@ -1527,4 +1540,13 @@ def goto(scopes, search_name=None, statement_path_offset=1):
|
|||||||
else:
|
else:
|
||||||
names += s.get_defined_names()
|
names += s.get_defined_names()
|
||||||
definitions = [n for n in names if n.names[-1] == search_name]
|
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
|
return definitions
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import parsing
|
|||||||
import builtin
|
import builtin
|
||||||
import debug
|
import debug
|
||||||
import evaluate
|
import evaluate
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
class Module(builtin.CachedModule):
|
class Module(builtin.CachedModule):
|
||||||
@@ -26,6 +27,7 @@ class Module(builtin.CachedModule):
|
|||||||
self._line_cache = None
|
self._line_cache = None
|
||||||
|
|
||||||
def _get_source(self):
|
def _get_source(self):
|
||||||
|
""" Just one time """
|
||||||
s = self.source
|
s = self.source
|
||||||
del self.source # memory efficiency
|
del self.source # memory efficiency
|
||||||
return s
|
return s
|
||||||
@@ -50,10 +52,17 @@ class ModuleWithCursor(Module):
|
|||||||
self._line_temp = None
|
self._line_temp = None
|
||||||
self._relevant_temp = None
|
self._relevant_temp = None
|
||||||
|
|
||||||
|
self.source = source
|
||||||
|
|
||||||
|
try:
|
||||||
|
del builtin.CachedModule.cache[self.path]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
# Call the parser already here, because it will be used anyways.
|
# Call the parser already here, because it will be used anyways.
|
||||||
# Also, the position is here important (which will not be used by
|
# Also, the position is here important (which will not be used by
|
||||||
# default), therefore fill the cache here.
|
# default), therefore fill the cache here.
|
||||||
self._parser = parsing.PyFuzzyParser(source, path, position)
|
self._parser = parsing.PyFuzzyParser(source, path, position)
|
||||||
|
builtin.CachedModule.cache[self.path] = time.time(), self._parser
|
||||||
|
|
||||||
def get_path_until_cursor(self):
|
def get_path_until_cursor(self):
|
||||||
""" Get the path under the cursor. """
|
""" Get the path under the cursor. """
|
||||||
|
|||||||
Reference in New Issue
Block a user