editor?.apply {
val shortenReferences = ShortenReferences.RETAIN_COMPANION
val codeStyleManager = CodeStyleManager.getInstance(project)
val reformatted = codeStyleManager.reformat(shortenReferences.process(previewPsi))
document.insertString(document.textLength, reformatted.text) //ToDo position should depend on writer
}