mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 23:39:39 +07:00
PY-52502 Duplicate completion variants when local variable is used as map key
GitOrigin-RevId: 463225922b2f0201b5d1ed2749f4175a77fd543f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c794a1f036
commit
feb3bdc4c2
@@ -122,15 +122,11 @@ public final class PyDictKeyNamesCompletionContributor extends CompletionContrib
|
||||
private static void addAdditionalKeys(final PsiFile file, final PsiElement operand, final DictKeyCompletionResultSet result) {
|
||||
Collection<PySubscriptionExpression> subscriptionExpressions = PsiTreeUtil.findChildrenOfType(file, PySubscriptionExpression.class);
|
||||
for (PySubscriptionExpression expr : subscriptionExpressions) {
|
||||
if (expr.getOperand().getText().equals(operand.getText())) {
|
||||
if (expr.getParent() instanceof PyAssignmentStatement assignmentStatement) {
|
||||
if (expr.equals(assignmentStatement.getLeftHandSideExpression())) {
|
||||
PyExpression key = expr.getIndexExpression();
|
||||
if (key != null) {
|
||||
result.addKey(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (expr.getOperand().getText().equals(operand.getText()) &&
|
||||
expr.getParent() instanceof PyAssignmentStatement assignmentStatement &&
|
||||
expr.equals(assignmentStatement.getLeftHandSideExpression()) &&
|
||||
expr.getIndexExpression() instanceof PyStringLiteralExpression key) {
|
||||
result.addKey(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,7 +137,9 @@ public final class PyDictKeyNamesCompletionContributor extends CompletionContrib
|
||||
private static void addDictLiteralKeys(final PyDictLiteralExpression dict, final DictKeyCompletionResultSet result) {
|
||||
PyKeyValueExpression[] keyValues = dict.getElements();
|
||||
for (PyKeyValueExpression expression : keyValues) {
|
||||
result.addKey(expression.getKey());
|
||||
if (expression.getKey() instanceof PyStringLiteralExpression key) {
|
||||
result.addKey(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,11 +152,9 @@ public final class PyDictKeyNamesCompletionContributor extends CompletionContrib
|
||||
myIsInsideString = isInsideString;
|
||||
}
|
||||
|
||||
void addKey(@NotNull PyExpression keyExpression) {
|
||||
void addKey(@NotNull PyStringLiteralExpression keyExpression) {
|
||||
if (myIsInsideString) {
|
||||
if (keyExpression instanceof PyStringLiteralExpression stringLiteralExpression) {
|
||||
addElement(stringLiteralExpression.getStringValue());
|
||||
}
|
||||
addElement(keyExpression.getStringValue());
|
||||
}
|
||||
else {
|
||||
addElement(keyExpression.getText());
|
||||
|
||||
Reference in New Issue
Block a user