forked from VimPlug/jedi
More direct parser usage removals.
This commit is contained in:
@@ -9,8 +9,7 @@ import inspect
|
|||||||
import types
|
import types
|
||||||
|
|
||||||
from jedi._compatibility import is_py3, builtins, unicode, is_py34
|
from jedi._compatibility import is_py3, builtins, unicode, is_py34
|
||||||
from jedi.parser import ParserWithRecovery
|
from jedi.parser.python import parse
|
||||||
from jedi.parser.python import load_grammar
|
|
||||||
from jedi.parser import tree as pt
|
from jedi.parser import tree as pt
|
||||||
|
|
||||||
modules = {}
|
modules = {}
|
||||||
@@ -62,9 +61,7 @@ def _load_faked_module(module):
|
|||||||
except IOError:
|
except IOError:
|
||||||
modules[module_name] = None
|
modules[module_name] = None
|
||||||
return
|
return
|
||||||
grammar = load_grammar(version='3.4')
|
modules[module_name] = parse(unicode(source))
|
||||||
module = ParserWithRecovery(grammar, unicode(source), module_name).module
|
|
||||||
modules[module_name] = module
|
|
||||||
|
|
||||||
if module_name == 'builtins' and not is_py3:
|
if module_name == 'builtins' and not is_py3:
|
||||||
# There are two implementations of `open` for either python 2/3.
|
# There are two implementations of `open` for either python 2/3.
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ from jedi._compatibility import u
|
|||||||
from jedi.common import unite
|
from jedi.common import unite
|
||||||
from jedi.evaluate import context
|
from jedi.evaluate import context
|
||||||
from jedi.evaluate.cache import memoize_default
|
from jedi.evaluate.cache import memoize_default
|
||||||
from jedi.parser import ParserWithRecovery
|
from jedi.parser.python import parse
|
||||||
from jedi.parser.python import load_grammar
|
|
||||||
from jedi.parser.tree import search_ancestor
|
from jedi.parser.tree import search_ancestor
|
||||||
from jedi.common import indent_block
|
from jedi.common import indent_block
|
||||||
from jedi.evaluate.iterable import SequenceLiteralContext, FakeSequence
|
from jedi.evaluate.iterable import SequenceLiteralContext, FakeSequence
|
||||||
@@ -134,9 +133,9 @@ def _evaluate_for_statement_string(module_context, string):
|
|||||||
# Take the default grammar here, if we load the Python 2.7 grammar here, it
|
# Take the default grammar here, if we load the Python 2.7 grammar here, it
|
||||||
# will be impossible to use `...` (Ellipsis) as a token. Docstring types
|
# will be impossible to use `...` (Ellipsis) as a token. Docstring types
|
||||||
# don't need to conform with the current grammar.
|
# don't need to conform with the current grammar.
|
||||||
p = ParserWithRecovery(load_grammar(), code.format(indent_block(string)))
|
module = parse(code.format(indent_block(string)))
|
||||||
try:
|
try:
|
||||||
funcdef = p.module.subscopes[0]
|
funcdef = module.subscopes[0]
|
||||||
# First pick suite, then simple_stmt and then the node,
|
# First pick suite, then simple_stmt and then the node,
|
||||||
# which is also not the last item, because there's a newline.
|
# which is also not the last item, because there's a newline.
|
||||||
stmt = funcdef.children[-1].children[-1].children[-2]
|
stmt = funcdef.children[-1].children[-1].children[-2]
|
||||||
|
|||||||
Reference in New Issue
Block a user