use of com.jetbrains.python.psi.PySequenceExpression in project intellij-community by JetBrains.
the class PyConvertLiteralToTupleIntention method prepareOriginalElementCopy.
@NotNull
@Override
protected PsiElement prepareOriginalElementCopy(@NotNull PsiElement copy) {
final PySequenceExpression sequenceExpression = unwrapCollection(copy);
final PyExpression[] elements = sequenceExpression.getElements();
if (elements.length == 1) {
final PyExpression onlyElement = elements[0];
final PsiElement next = PyPsiUtils.getNextNonCommentSibling(onlyElement, true);
if (next != null && next.getNode().getElementType() != PyTokenTypes.COMMA) {
final PyElementGenerator generator = PyElementGenerator.getInstance(copy.getProject());
final ASTNode anchor = onlyElement.getNode().getTreeNext();
sequenceExpression.getNode().addChild(generator.createComma(), anchor);
}
}
return copy;
}
Aggregations