mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-25 01:38:36 +08:00
made the module with cursor parser lazy
This commit is contained in:
+16
-10
@@ -54,16 +54,22 @@ class ModuleWithCursor(Module):
|
|||||||
|
|
||||||
self.source = source
|
self.source = source
|
||||||
|
|
||||||
try:
|
@property
|
||||||
del builtin.CachedModule.cache[self.path]
|
def parser(self):
|
||||||
except KeyError:
|
""" get the parser lazy """
|
||||||
pass
|
if not self._parser:
|
||||||
# Call the parser already here, because it will be used anyways.
|
try:
|
||||||
# Also, the position is here important (which will not be used by
|
del builtin.CachedModule.cache[self.path]
|
||||||
# default), therefore fill the cache here.
|
except KeyError:
|
||||||
self._parser = parsing.PyFuzzyParser(source, path, position)
|
pass
|
||||||
if self.path:
|
# Call the parser already here, because it will be used anyways.
|
||||||
builtin.CachedModule.cache[self.path] = time.time(), self._parser
|
# Also, the position is here important (which will not be used by
|
||||||
|
# default), therefore fill the cache here.
|
||||||
|
self._parser = parsing.PyFuzzyParser(self.source, self.path,
|
||||||
|
self.position)
|
||||||
|
if self.path:
|
||||||
|
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