boolean (@NotNull TestNGConfiguration configuration, @NotNull ConfigurationContext context, @NotNull Ref<PsiElement> sourceElement) { final PsiElement element = context.getPsiLocation(); final PsiFile containingFile = element != null ? element.getContainingFile() : null; if (containingFile == null) return false; if (JavaPsiFacade.getInstance(configuration.project).findPackage(TestNGUtil.TESTNG_PACKAGE) == null) { return false; } final VirtualFile virtualFile = containingFile.getVirtualFile(); if (virtualFile == null || !virtualFile.isValid()) return false; if (!TestNGUtil.isTestngSuiteFile(virtualFile)) return false; RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(context); setupConfigurationModule(context, configuration); final Module originalModule = configuration.getConfigurationModule().getModule(); configuration.getPersistantData().SUITE_NAME = virtualFile.getPath(); configuration.getPersistantData().TEST_OBJECT = TestType.SUITE.getType(); configuration.restoreOriginalModule(originalModule); configuration.setGeneratedName(); settings.setName(configuration.getName()); sourceElement.set(containingFile); return true; }