forked from VimPlug/jedi
Move a BaseContext to jedi.common.context.
This commit is contained in:
@@ -1 +1 @@
|
|||||||
from jedi.common.context import BaseContextSet
|
from jedi.common.context import BaseContextSet, BaseContext
|
||||||
|
|||||||
@@ -1,3 +1,16 @@
|
|||||||
|
class BaseContext(object):
|
||||||
|
def __init__(self, evaluator, parent_context=None):
|
||||||
|
self.evaluator = evaluator
|
||||||
|
self.parent_context = parent_context
|
||||||
|
|
||||||
|
def get_root_context(self):
|
||||||
|
context = self
|
||||||
|
while True:
|
||||||
|
if context.parent_context is None:
|
||||||
|
return context
|
||||||
|
context = context.parent_context
|
||||||
|
|
||||||
|
|
||||||
class BaseContextSet(object):
|
class BaseContextSet(object):
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
self._set = set(args)
|
self._set = set(args)
|
||||||
|
|||||||
@@ -3,23 +3,19 @@ from parso.python.tree import ExprStmt, CompFor
|
|||||||
from jedi import debug
|
from jedi import debug
|
||||||
from jedi._compatibility import Python3Method, zip_longest, unicode
|
from jedi._compatibility import Python3Method, zip_longest, unicode
|
||||||
from jedi.parser_utils import clean_scope_docstring, get_doc_with_call_signature
|
from jedi.parser_utils import clean_scope_docstring, get_doc_with_call_signature
|
||||||
from jedi.common import BaseContextSet
|
from jedi.common import BaseContextSet, BaseContext
|
||||||
|
|
||||||
|
|
||||||
class Context(object):
|
class Context(BaseContext):
|
||||||
"""
|
"""
|
||||||
Should be defined, otherwise the API returns empty types.
|
Should be defined, otherwise the API returns empty types.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
predefined_names = {}
|
||||||
|
tree_node = None
|
||||||
"""
|
"""
|
||||||
To be defined by subclasses.
|
To be defined by subclasses.
|
||||||
"""
|
"""
|
||||||
predefined_names = {}
|
|
||||||
tree_node = None
|
|
||||||
|
|
||||||
def __init__(self, evaluator, parent_context=None):
|
|
||||||
self.evaluator = evaluator
|
|
||||||
self.parent_context = parent_context
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def api_type(self):
|
def api_type(self):
|
||||||
@@ -27,13 +23,6 @@ class Context(object):
|
|||||||
# overwritten.
|
# overwritten.
|
||||||
return self.__class__.__name__.lower()
|
return self.__class__.__name__.lower()
|
||||||
|
|
||||||
def get_root_context(self):
|
|
||||||
context = self
|
|
||||||
while True:
|
|
||||||
if context.parent_context is None:
|
|
||||||
return context
|
|
||||||
context = context.parent_context
|
|
||||||
|
|
||||||
@debug.increase_indent
|
@debug.increase_indent
|
||||||
def execute(self, arguments):
|
def execute(self, arguments):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user