1
0
forked from VimPlug/jedi

Move the parsing away from user_context to api.py.

This commit is contained in:
Dave Halter
2016-06-27 08:48:36 +02:00
parent 0445d51d34
commit 969100e471
5 changed files with 20 additions and 25 deletions

View File

@@ -13,7 +13,9 @@ from __future__ import absolute_import
import string
import re
from collections import namedtuple
from io import StringIO
from jedi.parser.token import (tok_name, N_TOKENS, ENDMARKER, STRING, NUMBER, opmap,
NAME, OP, ERRORTOKEN, NEWLINE, INDENT, DEDENT)
from jedi._compatibility import is_py3
@@ -148,6 +150,9 @@ ALWAYS_BREAK_TOKENS = (';', 'import', 'class', 'def', 'try', 'except',
'finally', 'while', 'return')
Token = namedtuple('Token', ['type', 'string', 'start_pos', 'prefix'])
def source_tokens(source, use_exact_op_types=False):
"""Generate tokens from a the source code (string)."""
source = source

View File

@@ -27,15 +27,7 @@ class UserContextParser(object):
@cache.underscore_memoization
def _parser(self):
cache.invalidate_star_import_cache(self._path)
if self._use_fast_parser:
parser = FastParser(self._grammar, self._source, self._path)
# Don't pickle that module, because the main module is changing quickly
cache.save_parser(self._path, parser, pickling=False)
else:
parser = ParserWithRecovery(self._grammar, self._source, self._path)
self._parser_done_callback(parser)
return parser
pass
def module(self):
return self._parser().module