From 95c5b9a5e3e74977c2980c0c00dd7b8df6625248 Mon Sep 17 00:00:00 2001 From: David Halter Date: Mon, 4 Feb 2013 16:18:24 +0100 Subject: [PATCH] parsing.PyFuzzyParser -> Parser --- jedi/api.py | 2 +- jedi/builtin.py | 5 ++--- jedi/docstrings.py | 4 ++-- jedi/fast_parser.py | 6 +++--- jedi/modules.py | 2 +- jedi/parsing.py | 2 +- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/jedi/api.py b/jedi/api.py index 439fcbf2..7e24cc3c 100644 --- a/jedi/api.py +++ b/jedi/api.py @@ -188,7 +188,7 @@ class Script(object): return scopes def _get_under_cursor_stmt(self, cursor_txt): - r = parsing.PyFuzzyParser(cursor_txt, no_docstr=True) + r = parsing.Parser(cursor_txt, no_docstr=True) try: stmt = r.module.statements[0] except IndexError: diff --git a/jedi/builtin.py b/jedi/builtin.py index c1b48425..e90a89b0 100644 --- a/jedi/builtin.py +++ b/jedi/builtin.py @@ -205,8 +205,7 @@ class Parser(CachedModule): def _generate_code(scope, mixin_funcs={}, depth=0): """ - Generate a string, which uses python syntax as an input to the - PyFuzzyParser. + Generate a string, which uses python syntax as an input to the Parser. """ def get_doc(obj, indent=False): doc = inspect.getdoc(obj) @@ -461,7 +460,7 @@ class Builtin(object): class Container(object): FunctionType = types.FunctionType source = _generate_code(Container, depth=0) - parser = parsing.PyFuzzyParser(source, None) + parser = parsing.Parser(source, None) module = parser.module module.parent = self.scope typ = evaluate.follow_path(iter(['FunctionType']), module, module) diff --git a/jedi/docstrings.py b/jedi/docstrings.py index 9eff5004..a4cbf745 100644 --- a/jedi/docstrings.py +++ b/jedi/docstrings.py @@ -34,7 +34,7 @@ def follow_param(param): param_str) user_position = (2, 0) - p = parsing.PyFuzzyParser(param_str, None, user_position, + p = parsing.Parser(param_str, None, user_position, no_docstr=True) return evaluate.follow_statement(p.user_stmt) return [] @@ -98,7 +98,7 @@ def find_return_types(func): if not type_str: return [] - p = parsing.PyFuzzyParser(type_str, None, (1, 0), no_docstr=True) + p = parsing.Parser(type_str, None, (1, 0), no_docstr=True) p.user_stmt.parent = func return list(evaluate.follow_statement(p.user_stmt)) diff --git a/jedi/fast_parser.py b/jedi/fast_parser.py index 2b94c333..dbc4eb59 100644 --- a/jedi/fast_parser.py +++ b/jedi/fast_parser.py @@ -138,10 +138,10 @@ class CachedFastParser(type): """ This is a metaclass for caching `FastParser`. """ def __call__(self, source, module_path=None, user_position=None): if not settings.fast_parser: - return parsing.PyFuzzyParser(source, module_path, user_position) + return parsing.Parser(source, module_path, user_position) pi = cache.parser_cache.get(module_path, None) - if pi is None or isinstance(pi.parser, parsing.PyFuzzyParser): + if pi is None or isinstance(pi.parser, parsing.Parser): p = super(CachedFastParser, self).__call__(source, module_path, user_position) else: @@ -248,7 +248,7 @@ class FastParser(use_metaclass(CachedFastParser)): p.user_scope = self.scan_user_scope(m) \ or self.module else: - p = parsing.PyFuzzyParser(code[start:], + p = parsing.Parser(code[start:], self.module_path, self.user_position, line_offset=line_offset, stop_on_scope=True, top_module=self.module) diff --git a/jedi/modules.py b/jedi/modules.py index 9093cf71..60079470 100644 --- a/jedi/modules.py +++ b/jedi/modules.py @@ -218,7 +218,7 @@ class ModuleWithCursor(Module): length = settings.part_line_length offset = max(self.position[0] - length, 0) s = '\n'.join(self.source.splitlines()[offset:offset + length]) - self._part_parser = parsing.PyFuzzyParser(s, self.path, self.position, + self._part_parser = parsing.Parser(s, self.path, self.position, line_offset=offset) return self._part_parser diff --git a/jedi/parsing.py b/jedi/parsing.py index a7d600af..fa21f877 100644 --- a/jedi/parsing.py +++ b/jedi/parsing.py @@ -1235,7 +1235,7 @@ class ListComprehension(object): return "%s for %s in %s" % tuple(code) -class PyFuzzyParser(object): +class Parser(object): """ This class is used to parse a Python file, it then divides them into a class structure of different scopes.