forked from VimPlug/jedi
Replace Scope.subscopes with iter_funcdefs and iter_classdefs.
This commit is contained in:
@@ -7,6 +7,7 @@ mixing in Python code, the autocompletion should work much better for builtins.
|
||||
import os
|
||||
import inspect
|
||||
import types
|
||||
from itertools import chain
|
||||
|
||||
from jedi._compatibility import is_py3, builtins, unicode, is_py34
|
||||
from jedi.parser.python import parse
|
||||
@@ -74,7 +75,7 @@ def _load_faked_module(module):
|
||||
|
||||
|
||||
def _search_scope(scope, obj_name):
|
||||
for s in scope.subscopes:
|
||||
for s in chain(scope.iter_classdefs(), scope.iter_funcdefs()):
|
||||
if s.name.value == obj_name:
|
||||
return s
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ def _evaluate_for_statement_string(module_context, string):
|
||||
# don't need to conform with the current grammar.
|
||||
module = parse(code.format(indent_block(string)))
|
||||
try:
|
||||
funcdef = module.subscopes[0]
|
||||
funcdef = next(module.iter_funcdefs())
|
||||
# First pick suite, then simple_stmt and then the node,
|
||||
# which is also not the last item, because there's a newline.
|
||||
stmt = funcdef.children[-1].children[-1].children[-2]
|
||||
|
||||
@@ -275,7 +275,7 @@ def get_global_filters(evaluator, context, until_position, origin_scope):
|
||||
... y = None
|
||||
... '''))
|
||||
>>> module_node = script._get_module_node()
|
||||
>>> scope = module_node.subscopes[0]
|
||||
>>> scope = next(module_node.iter_funcdefs())
|
||||
>>> scope
|
||||
<Function: func@3-5>
|
||||
>>> context = script._get_module().create_context(scope)
|
||||
|
||||
@@ -270,7 +270,7 @@ def collections_namedtuple(evaluator, obj, arguments):
|
||||
)
|
||||
|
||||
# Parse source
|
||||
generated_class = parse(source, grammar=evaluator.grammar).subscopes[0]
|
||||
generated_class = next(parse(source, grammar=evaluator.grammar).iter_classdefs())
|
||||
return set([er.ClassContext(evaluator, generated_class, evaluator.BUILTINS)])
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user