Function0<JComponent> () { if (myDoNotChangeVar) return null; return new Function0<>() { @Override public JComponent invoke() { final JCheckBox varCheckbox = new NonFocusableCheckBox(KotlinBundle.message("checkbox.text.declare.with.var")); varCheckbox.setSelected(isVar); varCheckbox.addActionListener(new ActionListener() { @Override public void actionPerformed(@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); }); } }); return varCheckbox; } }; }