1
0
forked from VimPlug/jedi

Move toward ParserWithRecovery for the completion context.

It was simply not possible to do it with the normal parser, because of dedents.
This commit is contained in:
Dave Halter
2016-07-28 23:12:54 +02:00
parent f605359c16
commit 142f6652b5
2 changed files with 16 additions and 15 deletions

View File

@@ -289,7 +289,8 @@ class ParserWithRecovery(Parser):
:param module_path: The path of the module in the file system, may be None.
:type module_path: str
"""
def __init__(self, grammar, source, module_path=None, tokenizer=None):
def __init__(self, grammar, source, module_path=None, tokenizer=None,
start_parsing=True):
self.syntax_errors = []
self._omit_dedent_list = []
@@ -304,12 +305,16 @@ class ParserWithRecovery(Parser):
# if self.options["print_function"]:
# python_grammar = pygram.python_grammar_no_print_statement
# else:
super(ParserWithRecovery, self).__init__(grammar, source, tokenizer=tokenizer)
self.module = self._parsed
self.module.used_names = self._used_names
self.module.path = module_path
self.module.global_names = self._global_names
super(ParserWithRecovery, self).__init__(
grammar, source,
tokenizer=tokenizer,
start_parsing=start_parsing
)
if start_parsing:
self.module = self._parsed
self.module.used_names = self._used_names
self.module.path = module_path
self.module.global_names = self._global_names
def parse(self, tokenizer):
return super(ParserWithRecovery, self).parse(self._tokenize(self._tokenize(tokenizer)))