forked from VimPlug/jedi
remove parser from modules.py
This commit is contained in:
13
jedi/api.py
13
jedi/api.py
@@ -17,6 +17,7 @@ from itertools import chain
|
|||||||
|
|
||||||
from jedi.parser import Parser
|
from jedi.parser import Parser
|
||||||
from jedi.parser import representation as pr
|
from jedi.parser import representation as pr
|
||||||
|
from jedi.parser import fast
|
||||||
from jedi import debug
|
from jedi import debug
|
||||||
from jedi import settings
|
from jedi import settings
|
||||||
from jedi import helpers
|
from jedi import helpers
|
||||||
@@ -106,9 +107,15 @@ class Script(object):
|
|||||||
return '<%s: %s>' % (self.__class__.__name__, repr(self._source_path))
|
return '<%s: %s>' % (self.__class__.__name__, repr(self._source_path))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@cache.underscore_memoization
|
||||||
def _parser(self):
|
def _parser(self):
|
||||||
""" lazy parser."""
|
"""Get the parser lazy"""
|
||||||
return self._module.parser
|
path = self._source_path and os.path.abspath(self._source_path)
|
||||||
|
cache.invalidate_star_import_cache(path)
|
||||||
|
parser = fast.FastParser(self.source, path, self._pos)
|
||||||
|
# Don't pickle that module, because the main module is changing quickly
|
||||||
|
cache.save_parser(path, None, parser, pickling=False)
|
||||||
|
return parser
|
||||||
|
|
||||||
def completions(self):
|
def completions(self):
|
||||||
"""
|
"""
|
||||||
@@ -343,7 +350,7 @@ class Script(object):
|
|||||||
lower_priority_operators = ('()', '(', ',')
|
lower_priority_operators = ('()', '(', ',')
|
||||||
"""Operators that could hide callee."""
|
"""Operators that could hide callee."""
|
||||||
if next(context) in ('class', 'def'):
|
if next(context) in ('class', 'def'):
|
||||||
scopes = set([self._module.parser.user_scope])
|
scopes = set([self._parser.user_scope])
|
||||||
elif not goto_path:
|
elif not goto_path:
|
||||||
op = self._module.get_operator_under_cursor()
|
op = self._module.get_operator_under_cursor()
|
||||||
if op and op not in lower_priority_operators:
|
if op and op not in lower_priority_operators:
|
||||||
|
|||||||
@@ -72,16 +72,6 @@ class ModuleWithCursor(object):
|
|||||||
self._line_temp = None
|
self._line_temp = None
|
||||||
self._relevant_temp = None
|
self._relevant_temp = None
|
||||||
|
|
||||||
@property
|
|
||||||
@cache.underscore_memoization
|
|
||||||
def parser(self):
|
|
||||||
""" get the parser lazy """
|
|
||||||
cache.invalidate_star_import_cache(self.path)
|
|
||||||
parser = fast.FastParser(self.source, self.path, self.position)
|
|
||||||
# Don't pickle that module, because the main module is changing quickly
|
|
||||||
cache.save_parser(self.path, self.name, parser, pickling=False)
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def get_path_until_cursor(self):
|
def get_path_until_cursor(self):
|
||||||
""" Get the path under the cursor. """
|
""" Get the path under the cursor. """
|
||||||
if self._path_until_cursor is None: # small caching
|
if self._path_until_cursor is None: # small caching
|
||||||
|
|||||||
Reference in New Issue
Block a user