void () { myFixture.configureByText("a.java", """ interface Singleton { default boolean add(Object o) {} } class Usage { void foo() { Singleton.get<caret>Instance().add("a"); } } """); TemplateManagerImpl.setTemplateTesting(getTestRootDisposable()); doAction("Create method 'getInstance' in 'Singleton'"); TemplateState state = TemplateManagerImpl.getTemplateState(getEditor()); final Document document = getEditor().getDocument(); final int offset = getEditor().getCaretModel().getOffset(); WriteCommandAction.runWriteCommandAction(getProject(), () -> { PsiMethod method = PsiTreeUtil.getParentOfType(getFile().findElementAt(offset), PsiMethod.class); method.getModifierList().setModifierProperty(PsiModifier.STATIC, false); PsiDocumentManager.getInstance(getFile().getProject()).commitDocument(document); }); state.gotoEnd(false); }