mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-232631 Disable f-string-like completion in strings nodes outside of a string literal
String nodes are recognized by the lexer and, thus, can still appear even in syntactic contexts where an expression is not expected. In these cases the parser might wrap them in a PsiErrorElement instead of a PyStringLiteralExpression causing the reported CCE. GitOrigin-RevId: 161d88d6307e028ede462f707f01320df2169747
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1679f68e32
commit
fadb131582
+2
-1
@@ -39,7 +39,8 @@ public class PyFStringLikeCompletionContributor extends CompletionContributor {
|
||||
|
||||
private static final PsiElementPattern.Capture<PyPlainStringElement> INSIDE_NON_FORMATTED_STRING_ELEMENT =
|
||||
psiElement(PyPlainStringElement.class)
|
||||
.andNot(psiElement().inside(PyStringFormatCompletionContributor.FORMAT_STRING_CAPTURE));
|
||||
.withParent(PyStringLiteralExpression.class)
|
||||
.andNot(psiElement().inside(PyStringFormatCompletionContributor.FORMAT_STRING_CAPTURE));
|
||||
|
||||
public PyFStringLikeCompletionContributor() {
|
||||
extend(CompletionType.BASIC, INSIDE_NON_FORMATTED_STRING_ELEMENT, new CompletionProvider<CompletionParameters>() {
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
my_expr = 42
|
||||
def '{my_e<caret>'
|
||||
@@ -472,6 +472,11 @@ public class Py3CompletionTest extends PyTestCase {
|
||||
runWithLanguageLevel(LanguageLevel.getLatest(), this::doNegativeTest);
|
||||
}
|
||||
|
||||
// EA-232631
|
||||
public void testFStringLikeCompletionNotAvailableInStringElementsInSyntacticallyIllegalPosition() {
|
||||
runWithLanguageLevel(LanguageLevel.getLatest(), this::doNegativeTest);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return super.getTestDataPath() + "/completion";
|
||||
|
||||
Reference in New Issue
Block a user