void (final PyNamedParameter param) { PsiElement paren = getLastChild(); if (paren != null && ")".equals(paren.getText())) { ASTNode beforeWhat = paren.getNode(); // the closing paren will be this PyParameter[] params = getParameters(); final boolean hasDefaultValue = param.hasDefaultValue(); boolean isLast = true; for (PyParameter p : params) { if (!hasDefaultValue && p.hasDefaultValue()) { beforeWhat = p.getNode(); isLast = false; break; } if (p instanceof PyNamedParameter named) { if (named.isKeywordContainer() || named.isPositionalContainer()) { beforeWhat = p.getNode(); isLast = false; break; } } } final ASTNode previous = PyPsiUtils.getPrevNonWhitespaceSibling(beforeWhat); PyUtil.addListNode(this, param, beforeWhat, !isLast || params.length == 0 || previous.getElementType() == PyTokenTypes.COMMA, isLast, beforeWhat.getElementType() != PyTokenTypes.RPAR); } }