public TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, @NotNull PsiElement[] elements) throws IncorrectOperationException {
assert (elements.length == 1 && elements[0] != null) || PsiTreeUtil.findCommonParent(elements) == elements[0].getParent();
final PsiElement e = elements[0];
CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);
final PsiFileFactory factory = PsiFileFactory.getInstance(project);
final StringBuilder stringBuilder = new StringBuilder(myHead + "[{},\n");
stringBuilder.append(e.getText());
stringBuilder.append("\n]");
final PsiFile file = factory.createFileFromText("dummy.m", MathematicaFileType.INSTANCE, stringBuilder);
final FunctionCall[] func = PsiTreeUtil.getChildrenOfType(file, FunctionCall.class);
assert func != null && func[0] != null;
func[0] = (FunctionCall) codeStyleManager.reformat(func[0]);
PsiElement newElement = e.replace(func[0]);