mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
reverse use of tokenize, to get the command under the cursor
This commit is contained in:
15
modules.py
15
modules.py
@@ -35,22 +35,13 @@ class File(object):
|
||||
if not self.module_name and not self.source:
|
||||
raise AttributeError("Submit a module name or the source code")
|
||||
elif self.module_name:
|
||||
return self.load_module()
|
||||
return self._load_module()
|
||||
|
||||
def load_module(self):
|
||||
def _load_module(self):
|
||||
self._parser = parsing.PyFuzzyParser(self.source)
|
||||
del self.source # efficiency
|
||||
return self._parser
|
||||
|
||||
def get_line(self, line):
|
||||
if not self._line_cache:
|
||||
self._line_cache = self.source.split('\n')
|
||||
|
||||
if 1 <= line <= len(self._line_cache):
|
||||
return self._line_cache[line - 1]
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def find_module(point_path):
|
||||
"""
|
||||
Find a module with a path (of the module, like usb.backend.libusb10).
|
||||
|
||||
Reference in New Issue
Block a user