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):
|
||||
scopes = self._evaluator.eval_element(atom_expr)
|
||||
completion_names = []
|
||||
debug.dbg('possible completion scopes: %s', scopes)
|
||||
debug.dbg('trailer completion scopes: %s', scopes)
|
||||
for s in scopes:
|
||||
names = []
|
||||
for names_dict in s.names_dicts(search_global=False):
|
||||
|
||||
@@ -31,11 +31,16 @@ class MixedObject(object):
|
||||
self._evaluator = evaluator
|
||||
self.obj = obj
|
||||
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):
|
||||
# TODO is this needed?
|
||||
assert search_global is False
|
||||
return [LazyMixedNamesDict(self._evaluator, self, is_instance=False)]
|
||||
return [self.names_dict]
|
||||
|
||||
def api_type(self):
|
||||
mappings = {
|
||||
@@ -44,13 +49,13 @@ class MixedObject(object):
|
||||
'funcdef': 'function',
|
||||
'file_input': 'module',
|
||||
}
|
||||
return mappings[self._definition.type]
|
||||
return mappings[self.definition.type]
|
||||
|
||||
def __repr__(self):
|
||||
return '<%s: %s>' % (type(self).__name__, repr(self.obj))
|
||||
|
||||
def __getattr__(self, name):
|
||||
return getattr(self._definition, name)
|
||||
return getattr(self.definition, name)
|
||||
|
||||
|
||||
class MixedName(compiled.CompiledName):
|
||||
|
||||
@@ -46,6 +46,7 @@ from jedi import common
|
||||
from jedi.cache import underscore_memoization, cache_star_import
|
||||
from jedi.evaluate.cache import memoize_default, CachedMetaClass, NO_DEFAULT
|
||||
from jedi.evaluate import compiled
|
||||
from jedi.evaluate.compiled import mixed
|
||||
from jedi.evaluate import recursion
|
||||
from jedi.evaluate import iterable
|
||||
from jedi.evaluate import docstrings
|
||||
@@ -631,13 +632,20 @@ class FunctionExecution(Executed):
|
||||
def __init__(self, evaluator, base, *args, **kwargs):
|
||||
super(FunctionExecution, self).__init__(evaluator, base, *args, **kwargs)
|
||||
self._copy_dict = {}
|
||||
new_func = helpers.deep_ast_copy(base.base_func, new_elements=self._copy_dict)
|
||||
for child in new_func.children:
|
||||
funcdef = base.base_func
|
||||
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'):
|
||||
# Not all nodes are properly copied by deep_ast_copy.
|
||||
child.parent = self
|
||||
self.children = new_func.children
|
||||
self.names_dict = new_func.names_dict
|
||||
self.children = funcdef.children
|
||||
self.names_dict = funcdef.names_dict
|
||||
|
||||
@memoize_default(default=set())
|
||||
@recursion.execution_recursion_decorator
|
||||
|
||||
Reference in New Issue
Block a user