PsiMethod (Collection<PsiMember> selectedMembers, Map<String, String> params, TemplateResource template) { // generate code using velocity String evaluatedText = GenerationUtil .velocityGenerateCode(clazz, selectedMembers, params, template.getTemplate(), config.getSortElements(), config.isUseFullyQualifiedName()); // create psi newMethod named toString() final JVMElementFactory topLevelFactory = JVMElementFactories.getFactory(clazz.getLanguage(), clazz.getProject()); if (topLevelFactory == null) { return null; } try { return topLevelFactory.createMethodFromText(evaluatedText, clazz); } catch (IncorrectOperationException e) { logger.info(e); HintManager.getInstance().showErrorHint(editor, JavaBundle .message("hint.text.tostring.method.could.not.be.created.from.template", template.getFileName())); return null; } }