diff --git a/jedi/common.py b/jedi/common.py index b59ae150..1ee00fe1 100644 --- a/jedi/common.py +++ b/jedi/common.py @@ -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 diff --git a/jedi/dynamic.py b/jedi/dynamic.py index 3eb4601e..4b7ca505 100644 --- a/jedi/dynamic.py +++ b/jedi/dynamic.py @@ -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 diff --git a/jedi/fast_parser.py b/jedi/fast_parser.py index 7c5946ee..476e1523 100644 --- a/jedi/fast_parser.py +++ b/jedi/fast_parser.py @@ -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