mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-19 12:01:12 +08:00
Improvments to on import completion.
This commit is contained in:
@@ -134,7 +134,7 @@ class Script(object):
|
||||
importer = helpers.check_error_statements(
|
||||
self._evaluator, module, self._pos
|
||||
)
|
||||
print(importer.completion_names(self._evaluator, True))
|
||||
#print(importer.completion_names(self._evaluator, True))
|
||||
return [(name, module) for name in importer.completion_names(self._evaluator, True)]
|
||||
elif isinstance(user_stmt, pr.Import):
|
||||
# TODO this paragraph is necessary, but not sure it works.
|
||||
@@ -189,7 +189,10 @@ class Script(object):
|
||||
|
||||
if not path and not isinstance(user_stmt, pr.Import):
|
||||
# add keywords
|
||||
completions += ((k, b) for k in keywords.keyword_names(all=True))
|
||||
#completions += ((k, b) for k in keywords.keyword_names(all=True))
|
||||
pass
|
||||
# TODO delete? We should search for valid parser
|
||||
# transformations.
|
||||
|
||||
needs_dot = not dot and path
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ Helpers for the API
|
||||
"""
|
||||
import re
|
||||
|
||||
from jedi.parser import tree as pt
|
||||
from jedi.evaluate import imports
|
||||
|
||||
|
||||
@@ -47,5 +48,12 @@ def importer_from_error_statement(evaluator, module, error_statement, pos):
|
||||
for typ, nodes in error_statement.stack:
|
||||
if typ == 'dotted_name':
|
||||
names += nodes[::2]
|
||||
elif typ == 'import_from':
|
||||
for node in nodes:
|
||||
if isinstance(node, pt.Node) and node.type == 'dotted_name':
|
||||
names += node.children[::2]
|
||||
print(typ, nodes)
|
||||
|
||||
print('x', names)
|
||||
|
||||
return imports.get_importer(evaluator, names, module, level)
|
||||
|
||||
@@ -446,6 +446,7 @@ class _Importer(object):
|
||||
scope, rest = self.follow_file_system()
|
||||
if rest:
|
||||
# follow the rest of the import (not FS -> classes, functions)
|
||||
return []
|
||||
raise NotImplementedError
|
||||
# old
|
||||
return evaluator.follow_path(iter(rest), [scope], scope)
|
||||
|
||||
Reference in New Issue
Block a user