forked from VimPlug/jedi
Some more bug fixes for MixedObject.
This commit is contained in:
@@ -199,7 +199,7 @@ class Completion:
|
|||||||
def _trailer_completions(self, atom_expr):
|
def _trailer_completions(self, atom_expr):
|
||||||
scopes = self._evaluator.eval_element(atom_expr)
|
scopes = self._evaluator.eval_element(atom_expr)
|
||||||
completion_names = []
|
completion_names = []
|
||||||
debug.dbg('possible completion scopes: %s', scopes)
|
debug.dbg('trailer completion scopes: %s', scopes)
|
||||||
for s in scopes:
|
for s in scopes:
|
||||||
names = []
|
names = []
|
||||||
for names_dict in s.names_dicts(search_global=False):
|
for names_dict in s.names_dicts(search_global=False):
|
||||||
|
|||||||
@@ -31,11 +31,16 @@ class MixedObject(object):
|
|||||||
self._evaluator = evaluator
|
self._evaluator = evaluator
|
||||||
self.obj = obj
|
self.obj = obj
|
||||||
self.node_name = node_name
|
self.node_name = node_name
|
||||||
self._definition = node_name.get_definition()
|
self.definition = node_name.get_definition()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def names_dict(self):
|
||||||
|
return LazyMixedNamesDict(self._evaluator, self, is_instance=False)
|
||||||
|
|
||||||
def names_dicts(self, search_global):
|
def names_dicts(self, search_global):
|
||||||
|
# TODO is this needed?
|
||||||
assert search_global is False
|
assert search_global is False
|
||||||
return [LazyMixedNamesDict(self._evaluator, self, is_instance=False)]
|
return [self.names_dict]
|
||||||
|
|
||||||
def api_type(self):
|
def api_type(self):
|
||||||
mappings = {
|
mappings = {
|
||||||
@@ -44,13 +49,13 @@ class MixedObject(object):
|
|||||||
'funcdef': 'function',
|
'funcdef': 'function',
|
||||||
'file_input': 'module',
|
'file_input': 'module',
|
||||||
}
|
}
|
||||||
return mappings[self._definition.type]
|
return mappings[self.definition.type]
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<%s: %s>' % (type(self).__name__, repr(self.obj))
|
return '<%s: %s>' % (type(self).__name__, repr(self.obj))
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
return getattr(self._definition, name)
|
return getattr(self.definition, name)
|
||||||
|
|
||||||
|
|
||||||
class MixedName(compiled.CompiledName):
|
class MixedName(compiled.CompiledName):
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ from jedi import common
|
|||||||
from jedi.cache import underscore_memoization, cache_star_import
|
from jedi.cache import underscore_memoization, cache_star_import
|
||||||
from jedi.evaluate.cache import memoize_default, CachedMetaClass, NO_DEFAULT
|
from jedi.evaluate.cache import memoize_default, CachedMetaClass, NO_DEFAULT
|
||||||
from jedi.evaluate import compiled
|
from jedi.evaluate import compiled
|
||||||
|
from jedi.evaluate.compiled import mixed
|
||||||
from jedi.evaluate import recursion
|
from jedi.evaluate import recursion
|
||||||
from jedi.evaluate import iterable
|
from jedi.evaluate import iterable
|
||||||
from jedi.evaluate import docstrings
|
from jedi.evaluate import docstrings
|
||||||
@@ -631,13 +632,20 @@ class FunctionExecution(Executed):
|
|||||||
def __init__(self, evaluator, base, *args, **kwargs):
|
def __init__(self, evaluator, base, *args, **kwargs):
|
||||||
super(FunctionExecution, self).__init__(evaluator, base, *args, **kwargs)
|
super(FunctionExecution, self).__init__(evaluator, base, *args, **kwargs)
|
||||||
self._copy_dict = {}
|
self._copy_dict = {}
|
||||||
new_func = helpers.deep_ast_copy(base.base_func, new_elements=self._copy_dict)
|
funcdef = base.base_func
|
||||||
for child in new_func.children:
|
if isinstance(funcdef, mixed.MixedObject):
|
||||||
|
# The extra information in mixed is not needed anymore. We can just
|
||||||
|
# unpack it and give it the tree object.
|
||||||
|
funcdef = funcdef.definition
|
||||||
|
|
||||||
|
# Just overwrite the old version. We don't need it anymore.
|
||||||
|
funcdef = helpers.deep_ast_copy(funcdef, new_elements=self._copy_dict)
|
||||||
|
for child in funcdef.children:
|
||||||
if child.type not in ('operator', 'keyword'):
|
if child.type not in ('operator', 'keyword'):
|
||||||
# Not all nodes are properly copied by deep_ast_copy.
|
# Not all nodes are properly copied by deep_ast_copy.
|
||||||
child.parent = self
|
child.parent = self
|
||||||
self.children = new_func.children
|
self.children = funcdef.children
|
||||||
self.names_dict = new_func.names_dict
|
self.names_dict = funcdef.names_dict
|
||||||
|
|
||||||
@memoize_default(default=set())
|
@memoize_default(default=set())
|
||||||
@recursion.execution_recursion_decorator
|
@recursion.execution_recursion_decorator
|
||||||
|
|||||||
Reference in New Issue
Block a user