forked from VimPlug/jedi
move all the parser stuff into a seperate package
This commit is contained in:
@@ -23,7 +23,7 @@ import keyword
|
|||||||
from jedi._compatibility import next, StringIO
|
from jedi._compatibility import next, StringIO
|
||||||
from jedi import debug
|
from jedi import debug
|
||||||
from jedi import common
|
from jedi import common
|
||||||
from jedi import parsing_representation as pr
|
from jedi.parser import representation as pr
|
||||||
|
|
||||||
|
|
||||||
class Parser(object):
|
class Parser(object):
|
||||||
@@ -7,8 +7,8 @@ import re
|
|||||||
|
|
||||||
from jedi._compatibility import use_metaclass
|
from jedi._compatibility import use_metaclass
|
||||||
from jedi import settings
|
from jedi import settings
|
||||||
from jedi import parsing
|
from jedi.parser import Parser
|
||||||
from jedi import parsing_representation as pr
|
from jedi.parser import representation as pr
|
||||||
from jedi import cache
|
from jedi import cache
|
||||||
from jedi import common
|
from jedi import common
|
||||||
|
|
||||||
@@ -62,10 +62,10 @@ class CachedFastParser(type):
|
|||||||
""" This is a metaclass for caching `FastParser`. """
|
""" This is a metaclass for caching `FastParser`. """
|
||||||
def __call__(self, source, module_path=None, user_position=None):
|
def __call__(self, source, module_path=None, user_position=None):
|
||||||
if not settings.fast_parser:
|
if not settings.fast_parser:
|
||||||
return parsing.Parser(source, module_path, user_position)
|
return Parser(source, module_path, user_position)
|
||||||
|
|
||||||
pi = cache.parser_cache.get(module_path, None)
|
pi = cache.parser_cache.get(module_path, None)
|
||||||
if pi is None or isinstance(pi.parser, parsing.Parser):
|
if pi is None or isinstance(pi.parser, Parser):
|
||||||
p = super(CachedFastParser, self).__call__(source, module_path,
|
p = super(CachedFastParser, self).__call__(source, module_path,
|
||||||
user_position)
|
user_position)
|
||||||
else:
|
else:
|
||||||
@@ -406,7 +406,7 @@ class FastParser(use_metaclass(CachedFastParser)):
|
|||||||
if nodes[index].code != code:
|
if nodes[index].code != code:
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
except ValueError:
|
except ValueError:
|
||||||
p = parsing.Parser(parser_code, self.module_path,
|
p = Parser(parser_code, self.module_path,
|
||||||
self.user_position, offset=(line_offset, 0),
|
self.user_position, offset=(line_offset, 0),
|
||||||
is_fast_parser=True, top_module=self.module,
|
is_fast_parser=True, top_module=self.module,
|
||||||
no_docstr=no_docstr)
|
no_docstr=no_docstr)
|
||||||
Reference in New Issue
Block a user