forked from VimPlug/jedi
fix fast_parser problems with asserts
This commit is contained in:
@@ -77,6 +77,7 @@ class NoErrorTokenizer(object):
|
||||
# We just ignore this error, I try to handle it earlier - as
|
||||
# good as possible
|
||||
debug.warning('parentheses not closed error')
|
||||
return self.__next__()
|
||||
except IndentationError:
|
||||
# This is an error, that tokenize may produce, because the code
|
||||
# is not indented as it should. Here it just ignores this line
|
||||
|
||||
@@ -19,6 +19,7 @@ import debug
|
||||
import builtin
|
||||
import imports
|
||||
import api_classes
|
||||
import fast_parser
|
||||
|
||||
# This is something like the sys.path, but only for searching params. It means
|
||||
# that this is the order in which Jedi searches params.
|
||||
@@ -440,7 +441,7 @@ def check_flow_information(flow, search_name, pos):
|
||||
ensures that `k` is a string.
|
||||
"""
|
||||
result = []
|
||||
if isinstance(flow, parsing.Scope) and not result:
|
||||
if isinstance(flow, (parsing.Scope, fast_parser.Module)) and not result:
|
||||
for ass in reversed(flow.asserts):
|
||||
if pos is None or ass.start_pos > pos:
|
||||
continue
|
||||
|
||||
@@ -21,10 +21,14 @@ class Module(parsing.Simple, parsing.Module):
|
||||
parsers. """
|
||||
self.cache = {}
|
||||
|
||||
def _get(self, name, operation, *args, **kwargs):
|
||||
def _get(self, name, operation, execute=False, *args, **kwargs):
|
||||
key = (name, args, frozenset(kwargs.items()))
|
||||
if key not in self.cache:
|
||||
objs = (getattr(p.module, name)(*args, **kwargs) for p in self.parsers)
|
||||
if execute:
|
||||
objs = (getattr(p.module, name)(*args, **kwargs)
|
||||
for p in self.parsers)
|
||||
else:
|
||||
objs = (getattr(p.module, name) for p in self.parsers)
|
||||
self.cache[key] = reduce(operation, objs)
|
||||
return self.cache[key]
|
||||
|
||||
@@ -44,7 +48,7 @@ class Module(parsing.Simple, parsing.Module):
|
||||
}
|
||||
if name in operators:
|
||||
return lambda *args, **kwargs: self._get(name, operators[name],
|
||||
*args, **kwargs)
|
||||
True, *args, **kwargs)
|
||||
elif name in properties:
|
||||
return self._get(name, properties[name])
|
||||
else:
|
||||
@@ -172,7 +176,8 @@ class FastParser(use_metaclass(CachedFastParser)):
|
||||
|
||||
def _parse(self, code):
|
||||
""" :type code: str """
|
||||
r = r'(?:\n(?:def|class|@.*?\n(?:def|class))|^).*?(?=\n(?:def|class|@)|$)'
|
||||
r = r'(?:\n(?:def|class|@.*?\n(?:def|class))|^).*?' \
|
||||
r'(?=\n(?:def|class|@)|$)'
|
||||
parts = re.findall(r, code, re.DOTALL)
|
||||
|
||||
line_offset = 0
|
||||
|
||||
Reference in New Issue
Block a user