1
0
forked from VimPlug/jedi

user_position removed from Parser. yikes!

This commit is contained in:
Dave Halter
2014-01-17 02:58:03 +01:00
parent 6063093151
commit aa59aee3dc
3 changed files with 10 additions and 15 deletions

View File

@@ -34,15 +34,12 @@ class Parser(object):
:type source: str
:param module_path: The path of the module in the file system, may be None.
:type module_path: str
:param user_position: The line/column, the user is currently on.
:type user_position: tuple(int, int)
:param no_docstr: If True, a string at the beginning is not a docstr.
:param is_fast_parser: -> for fast_parser
:param top_module: Use this module as a parent instead of `self.module`.
"""
def __init__(self, source, module_path=None, user_position=None,
no_docstr=False, offset=(0, 0), is_fast_parser=None,
top_module=None):
def __init__(self, source, module_path=None, no_docstr=False,
offset=(0, 0), is_fast_parser=None, top_module=None):
self.no_docstr = no_docstr
self.start_pos = self.end_pos = 1 + offset[0], offset[1]

View File

@@ -57,17 +57,16 @@ class Module(pr.Simple, pr.Module):
class CachedFastParser(type):
""" This is a metaclass for caching `FastParser`. """
def __call__(self, source, module_path=None, user_position=None):
def __call__(self, source, module_path=None):
if not settings.fast_parser:
return Parser(source, module_path, user_position)
return Parser(source, module_path)
pi = cache.parser_cache.get(module_path, None)
if pi is None or isinstance(pi.parser, Parser):
p = super(CachedFastParser, self).__call__(source, module_path,
user_position)
p = super(CachedFastParser, self).__call__(source, module_path)
else:
p = pi.parser # pi is a `cache.ParserCacheItem`
p.update(source, user_position)
p.update(source)
return p
@@ -182,7 +181,7 @@ class ParserNode(object):
class FastParser(use_metaclass(CachedFastParser)):
def __init__(self, code, module_path=None, user_position=None):
def __init__(self, code, module_path=None):
# set values like `pr.Module`.
self.module_path = module_path
@@ -198,8 +197,7 @@ class FastParser(use_metaclass(CachedFastParser)):
self.parsers[:] = []
raise
def update(self, code, user_position=None):
self.user_position = user_position
def update(self, code):
self.reset_caches()
try:

View File

@@ -192,9 +192,9 @@ class UserContextParser(object):
def _parser(self):
cache.invalidate_star_import_cache(self._path)
if self._no_docstr:
parser = Parser(self._source, self._path, self._position, no_docstr=self._no_docstr)
parser = Parser(self._source, self._path, no_docstr=self._no_docstr)
else:
parser = FastParser(self._source, self._path, self._position)
parser = FastParser(self._source, self._path)
# Don't pickle that module, because the main module is changing quickly
cache.save_parser(self._path, None, parser, pickling=False)
return parser