PsiMethod (@NotNull PsiClass myTargetClass) { Project project = myTargetClass.getProject(); JVMElementFactory elementFactory = JVMElementFactories.getFactory(myTargetClass.getLanguage(), project); if (elementFactory == null) { elementFactory = JavaPsiFacade.getElementFactory(project); } String methodText = mySignature + (myTargetClass.isInterface() ? ";" : "{" + myBody + "}"); return elementFactory.createMethodFromText(methodText, null); }