Completion after as in imports should not be possible.

Fixes #841.
This commit is contained in:
Dave Halter
2017-09-10 11:27:57 +02:00
parent c25a4a00df
commit c05f1d3ccc
2 changed files with 7 additions and 5 deletions

View File

@@ -146,7 +146,11 @@ class Completion:
nodes = list(self.stack.get_nodes())
if "import_stmt" in symbol_names:
if nodes and nodes[-1] in ('as', 'def', 'class'):
# No completions for ``with x as foo`` and ``import x as foo``.
# Also true for defining names as a class or function.
return list(self._get_class_context_completions(is_function=True))
elif "import_stmt" in symbol_names:
level = 0
only_modules = True
level, names = self._parse_dotted_names(nodes)
@@ -161,10 +165,6 @@ class Completion:
level,
only_modules
)
elif nodes and nodes[-1] in ('as', 'def', 'class'):
# No completions for ``with x as foo`` and ``import x as foo``.
# Also true for defining names as a class or function.
return list(self._get_class_context_completions(is_function=True))
elif symbol_names[-1] in ('trailer', 'dotted_name') and nodes[-1] == '.':
dot = self._module_node.get_leaf_for_position(self._position)
completion_names += self._trailer_completions(dot.get_previous_leaf())

View File

@@ -43,6 +43,8 @@ from . import some_variable
from . import arrays
#? []
from . import import_tree as ren
#? []
import json as
import os
#? os.path.join