mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 14:34:31 +08:00
Fix context completions and super calls.
This commit is contained in:
@@ -232,22 +232,21 @@ class Completion:
|
||||
"""
|
||||
Autocomplete inherited methods when overriding in child class.
|
||||
"""
|
||||
return
|
||||
leaf = self._module_node.get_leaf_for_position(self._position, include_prefixes=True)
|
||||
cls = leaf.get_parent_until(tree.Class)
|
||||
if isinstance(cls, (tree.Class, tree.Function)):
|
||||
# Complete the methods that are defined in the super classes.
|
||||
cls = self._evaluator.wrap(cls)
|
||||
random_context = self._module_context.create_context(cls)
|
||||
else:
|
||||
return
|
||||
|
||||
if cls.start_pos[1] >= leaf.start_pos[1]:
|
||||
return
|
||||
|
||||
filters = cls.get_filters(search_global=False, is_instance=True)
|
||||
filters = random_context.get_filters(search_global=False, is_instance=True)
|
||||
# The first dict is the dictionary of class itself.
|
||||
next(filters)
|
||||
for filter in filters:
|
||||
for name in filter.values():
|
||||
if (name.parent.type == 'funcdef') == is_function:
|
||||
if (name.api_type == 'function') == is_function:
|
||||
yield name
|
||||
|
||||
@@ -255,6 +255,7 @@ class CompiledName(AbstractNameDefinition):
|
||||
name = None
|
||||
return '<%s: (%s).%s>' % (self.__class__.__name__, name, self.string_name)
|
||||
|
||||
@property
|
||||
def api_type(self):
|
||||
return self.infer()[0].api_type
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ def builtins_super(evaluator, types, objects, context):
|
||||
# TODO make this able to detect multiple inheritance super
|
||||
if isinstance(context, InstanceFunctionExecution):
|
||||
su = context.instance.py__class__().py__bases__()
|
||||
return su[0].infer()
|
||||
return unite(context.execute_evaluated() for context in su[0].infer())
|
||||
return set()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user