forked from VimPlug/jedi
fixed more import problems (also with the import usage), definitely fixes davidhalter/jedi-vim#152
This commit is contained in:
@@ -112,7 +112,8 @@ class Script(object):
|
||||
names = s.get_magic_method_names()
|
||||
else:
|
||||
if isinstance(s, imports.ImportPath):
|
||||
if like == 'import':
|
||||
under = like + self._module.get_path_after_cursor()
|
||||
if under == 'import':
|
||||
if not completion_line.endswith('import import'):
|
||||
continue
|
||||
a = s.import_stmt.alias
|
||||
|
||||
@@ -153,14 +153,16 @@ class ImportPath(pr.Base):
|
||||
return pr.Name(self.GlobalNamespace, [(name, inf_pos)],
|
||||
inf_pos, inf_pos, self.import_stmt)
|
||||
|
||||
if not search_path:
|
||||
search_path = self.sys_path_with_modifications()
|
||||
names = []
|
||||
inf_pos = float('inf'), float('inf')
|
||||
# add builtin module names
|
||||
if search_path is None:
|
||||
names += [generate_name(name) for name in sys.builtin_module_names]
|
||||
|
||||
if search_path is None:
|
||||
search_path = self.sys_path_with_modifications()
|
||||
for module_loader, name, is_pkg in pkgutil.iter_modules(search_path):
|
||||
names.append(generate_name(name))
|
||||
# add builtin module names
|
||||
names += [generate_name(name) for name in sys.builtin_module_names]
|
||||
return names
|
||||
|
||||
def sys_path_with_modifications(self):
|
||||
|
||||
@@ -208,9 +208,11 @@ class ModuleWithCursor(Module):
|
||||
Return the path under the cursor. If there is a rest of the path left,
|
||||
it will be added to the stuff before it.
|
||||
"""
|
||||
return self.get_path_until_cursor() + self.get_path_after_cursor()
|
||||
|
||||
def get_path_after_cursor(self):
|
||||
line = self.get_line(self.position[0])
|
||||
after = re.search("[\w\d]*", line[self.position[1]:]).group(0)
|
||||
return self.get_path_until_cursor() + after
|
||||
return re.search("[\w\d]*", line[self.position[1]:]).group(0)
|
||||
|
||||
def get_operator_under_cursor(self):
|
||||
line = self.get_line(self.position[0])
|
||||
|
||||
@@ -211,7 +211,9 @@ import datetime.
|
||||
#? []
|
||||
import datetime.date
|
||||
|
||||
#? 18 ['mod1', 'random', 'pkg', 'rename1', 'rename2', 'import', 'recurse_class1', 'recurse_class2']
|
||||
#? 18 ['import']
|
||||
from import_tree. import pkg
|
||||
#? 17 ['mod1', 'random', 'pkg', 'rename1', 'rename2', 'recurse_class1', 'recurse_class2']
|
||||
from import_tree. import pkg
|
||||
|
||||
#? 18 ['pkg']
|
||||
|
||||
Reference in New Issue
Block a user