forked from VimPlug/jedi
parsing.PyFuzzyParser -> Parser
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user