1
0
forked from VimPlug/jedi

More direct parser usage removals.

This commit is contained in:
Dave Halter
2017-03-14 19:31:54 +01:00
parent 717bfeb574
commit 9efb3f0af2
2 changed files with 5 additions and 9 deletions

View File

@@ -9,8 +9,7 @@ import inspect
import types
from jedi._compatibility import is_py3, builtins, unicode, is_py34
from jedi.parser import ParserWithRecovery
from jedi.parser.python import load_grammar
from jedi.parser.python import parse
from jedi.parser import tree as pt
modules = {}
@@ -62,9 +61,7 @@ def _load_faked_module(module):
except IOError:
modules[module_name] = None
return
grammar = load_grammar(version='3.4')
module = ParserWithRecovery(grammar, unicode(source), module_name).module
modules[module_name] = module
modules[module_name] = parse(unicode(source))
if module_name == 'builtins' and not is_py3:
# There are two implementations of `open` for either python 2/3.

View File

@@ -22,8 +22,7 @@ from jedi._compatibility import u
from jedi.common import unite
from jedi.evaluate import context
from jedi.evaluate.cache import memoize_default
from jedi.parser import ParserWithRecovery
from jedi.parser.python import load_grammar
from jedi.parser.python import parse
from jedi.parser.tree import search_ancestor
from jedi.common import indent_block
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
# will be impossible to use `...` (Ellipsis) as a token. Docstring types
# 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:
funcdef = p.module.subscopes[0]
funcdef = module.subscopes[0]
# 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]