1
0
forked from VimPlug/jedi

removed some functions from classes

This commit is contained in:
Dave Halter
2014-01-28 23:51:34 +01:00
parent 9cfa8fead0
commit 13696018a2
3 changed files with 11 additions and 33 deletions

View File

@@ -84,7 +84,7 @@ class Script(object):
raise ValueError('`column` parameter is not in a valid range.') raise ValueError('`column` parameter is not in a valid range.')
self._pos = line, column self._pos = line, column
classes.clear_caches() cache.clear_caches()
debug.reset_time() debug.reset_time()
self.source = common.source_to_unicode(source, encoding) self.source = common.source_to_unicode(source, encoding)
self._user_context = UserContext(self.source, self._pos) self._user_context = UserContext(self.source, self._pos)

View File

@@ -4,9 +4,8 @@ classes are the much bigger part of the whole API, because they contain the
interesting information about completion and goto operations. interesting information about completion and goto operations.
""" """
import warnings import warnings
import functools
from jedi._compatibility import unicode, next from jedi._compatibility import next, unicode
from jedi import settings from jedi import settings
from jedi import common from jedi import common
from jedi import cache from jedi import cache
@@ -19,24 +18,17 @@ from jedi.api import keywords
from jedi.evaluate.finder import get_names_of_scope from jedi.evaluate.finder import get_names_of_scope
def clear_caches(): def defined_names(evaluator, scope):
""" """
Clear all caches of this and related modules. The only cache that will not List sub-definitions (e.g., methods in class).
be deleted is the module cache.
"""
cache.clear_caches()
:type scope: Scope
def _clear_caches_after_call(func): :rtype: list of Definition
""" """
Clear caches just before returning a value. pair = next(get_names_of_scope(evaluator, scope, star_search=False,
""" include_builtin=False), None)
@functools.wraps(func) names = pair[1] if pair else []
def wrapper(*args, **kwds): return [Definition(evaluator, d) for d in sorted(names, key=lambda s: s.start_pos)]
result = func(*args, **kwds)
clear_caches()
return result
return wrapper
class BaseDefinition(object): class BaseDefinition(object):
@@ -413,7 +405,7 @@ class Completion(BaseDefinition):
return [self] return [self]
defs = [BaseDefinition(self._evaluator, d, d.start_pos) for d in defs] defs = [BaseDefinition(self._evaluator, d, d.start_pos) for d in defs]
clear_caches() cache.clear_caches()
return defs return defs
def __repr__(self): def __repr__(self):
@@ -544,19 +536,6 @@ class Definition(BaseDefinition):
return defined_names(self._evaluator, d) return defined_names(self._evaluator, d)
def defined_names(evaluator, scope):
"""
List sub-definitions (e.g., methods in class).
:type scope: Scope
:rtype: list of Definition
"""
pair = next(get_names_of_scope(evaluator, scope, star_search=False,
include_builtin=False), None)
names = pair[1] if pair else []
return [Definition(evaluator, d) for d in sorted(names, key=lambda s: s.start_pos)]
class CallDef(object): class CallDef(object):
""" """
`CallDef` objects is the return value of `Script.function_definition`. `CallDef` objects is the return value of `Script.function_definition`.

View File

@@ -1,7 +1,6 @@
""" """
Helpers for the API Helpers for the API
""" """
from jedi import debug from jedi import debug
from jedi.evaluate import helpers from jedi.evaluate import helpers
from jedi.parser import representation as pr from jedi.parser import representation as pr