void (@NotNull PsiElement wrappable, @NotNull Document doc) { TextRange rangeToParenthesise; if (wrappable instanceof PyFromImportStatement fromImportStatement) { rangeToParenthesise = getRangeForPsiElementArray(fromImportStatement.getImportElements()); } else if (wrappable instanceof PyWithStatement withStatement) { rangeToParenthesise = getRangeForPsiElementArray(withStatement.getWithItems()); } else { rangeToParenthesise = wrappable.getTextRange(); } if (rangeToParenthesise != null) { doc.insertString(rangeToParenthesise.getEndOffset(), ")"); doc.insertString(rangeToParenthesise.getStartOffset(), "("); } }