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