mirror of
https://github.com/davidhalter/jedi.git
synced 2026-08-31 03:47:13 +08:00
made the module with cursor parser lazy
This commit is contained in:
+7
-1
@@ -54,6 +54,10 @@ class ModuleWithCursor(Module):
|
|||||||
|
|
||||||
self.source = source
|
self.source = source
|
||||||
|
|
||||||
|
@property
|
||||||
|
def parser(self):
|
||||||
|
""" get the parser lazy """
|
||||||
|
if not self._parser:
|
||||||
try:
|
try:
|
||||||
del builtin.CachedModule.cache[self.path]
|
del builtin.CachedModule.cache[self.path]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -61,9 +65,11 @@ class ModuleWithCursor(Module):
|
|||||||
# Call the parser already here, because it will be used anyways.
|
# Call the parser already here, because it will be used anyways.
|
||||||
# Also, the position is here important (which will not be used by
|
# Also, the position is here important (which will not be used by
|
||||||
# default), therefore fill the cache here.
|
# default), therefore fill the cache here.
|
||||||
self._parser = parsing.PyFuzzyParser(source, path, position)
|
self._parser = parsing.PyFuzzyParser(self.source, self.path,
|
||||||
|
self.position)
|
||||||
if self.path:
|
if self.path:
|
||||||
builtin.CachedModule.cache[self.path] = time.time(), self._parser
|
builtin.CachedModule.cache[self.path] = time.time(), self._parser
|
||||||
|
return self._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. """
|
||||||
|
|||||||
Reference in New Issue
Block a user