CreateMethodQuickFix (PsiAnnotationMemberValue provider, @NotNull PsiClass providerClass, PsiClass topLevelClass) { final String name = StringUtil.unquoteString(provider.getText()); FileTemplateDescriptor templateDesc = new TestNGFramework().getParametersMethodFileTemplateDescriptor(); assert templateDesc != null; final FileTemplate fileTemplate = FileTemplateManager.getInstance(provider.getProject()).getCodeTemplate(templateDesc.getFileName()); String body = ""; try { final Properties attributes = FileTemplateManager.getInstance(provider.getProject()).getDefaultProperties(); attributes.setProperty(FileTemplate.ATTRIBUTE_NAME, name); body = fileTemplate.getText(attributes); body = body.replace("${BODY}\n", ""); final PsiMethod methodFromTemplate = JavaPsiFacade.getElementFactory(providerClass.getProject()).createMethodFromText(body, providerClass); final PsiCodeBlock methodBody = methodFromTemplate.getBody(); if (methodBody != null) { body = StringUtil.trimEnd(StringUtil.trimStart(methodBody.getText(), "{"), "}"); } else { body = ""; } } catch (Exception ignored) {} if (StringUtil.isEmptyOrSpaces(body)) { body = "return new Object[][]{};"; } String signature = "@" + DataProvider.class.getName() + " public "; if (providerClass == topLevelClass) { signature += "static "; } signature += "Object[][] " + name + "()"; return CreateMethodQuickFix.createFix(providerClass, signature, body); }