PY-75537 Slightly simplified PyAssignmentStatementImpl.getTargetsToValuesMapping()

GitOrigin-RevId: 41f02b5c164380ad978cfa66eb36bb5b97189855
This commit is contained in:
Petr
2024-10-16 10:54:46 +00:00
committed by intellij-monorepo-bot
parent 05942bee35
commit 47e2c8c0bc
@@ -51,10 +51,11 @@ public class PyAssignmentStatementImpl extends PyElementImpl implements PyAssign
if (!PsiTreeUtil.hasErrorElements(this)) { // no parse errors
PyExpression[] constituents = PsiTreeUtil.getChildrenOfType(this, PyExpression.class); // "a = b = c" -> [a, b, c]
if (constituents != null && constituents.length > 1) {
PyExpression rhs = constituents[constituents.length - 1]; // last
List<PyExpression> lhses = Lists.newArrayList(constituents);
if (!lhses.isEmpty()) lhses.remove(lhses.size() - 1); // copy all but last; most often it's one element.
for (PyExpression lhs : lhses) mapToValues(lhs, rhs, ret);
int lastIndex = constituents.length - 1;
PyExpression rhs = constituents[lastIndex];
for (int i = 0; i < lastIndex; i++) {
mapToValues(constituents[i], rhs, ret);
}
}
}
return ret;