void (@NotNull ActionEvent e) { runWriteCommandAction(myProject, getCommandName(), getCommandName(), () -> { PsiDocumentManager.getInstance(myProject).commitDocument(myEditor.getDocument()); KtPsiFactory psiFactory = new KtPsiFactory(myProject); PsiElement keyword = varCheckbox.isSelected() ? psiFactory.createVarKeyword() : psiFactory.createValKeyword(); PsiElement valOrVar = myDeclaration instanceof KtProperty ? ((KtProperty) myDeclaration).getValOrVarKeyword() : ((KtParameter) myDeclaration).getValOrVarKeyword(); valOrVar.replace(keyword); }); }