mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-15075 Suggest "import" after dots in relative import only after additional whitespace
This commit is contained in:
+7
-2
@@ -254,8 +254,13 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
public static final PsiElementPattern.Capture<PsiElement> IN_FROM_IMPORT_AFTER_REF =
|
||||
psiElement().afterLeaf(
|
||||
or(psiElement().withElementType(PyTokenTypes.IDENTIFIER).inside(PyReferenceExpression.class),
|
||||
psiElement().withElementType(PyTokenTypes.DOT))
|
||||
).inside(PyFromImportStatement.class);
|
||||
psiElement().with(new PatternCondition<PsiElement>("dotFollowedByWhitespace") {
|
||||
@Override
|
||||
public boolean accepts(@NotNull PsiElement element, ProcessingContext context) {
|
||||
return element.getNode().getElementType() == PyTokenTypes.DOT && element.getNextSibling() instanceof PsiWhiteSpace;
|
||||
}
|
||||
}))
|
||||
).inside(PyFromImportStatement.class);
|
||||
|
||||
public static final ElementPattern<PsiElement> IN_WITH_AFTER_REF =
|
||||
psiElement().afterLeaf(psiElement().inside(psiElement(PyWithItem.class).with(new PatternCondition<PyWithItem>("withoutAsKeyword") {
|
||||
|
||||
@@ -227,4 +227,13 @@ public class PythonKeywordCompletionTest extends PyTestCase {
|
||||
"finally:\n" +
|
||||
" pass\n<caret>"), "except");
|
||||
}
|
||||
|
||||
// PY-15075
|
||||
public void testImportAfterWhitespaceInRelativeImport() {
|
||||
List<String> variants = doTestByText("from ...<caret>");
|
||||
assertDoesntContain(variants, "import");
|
||||
|
||||
variants = doTestByText("from ... <caret>");
|
||||
assertContainsElements(variants, "import");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user