Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
17,300
void () { UIUtil.invokeAndWaitIfNeeded(new Runnable() { @Override public void run() { try { final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory(); final TestFixtureBuilder<IdeaProjectTestFixture> testFixtureBuilder = fixtureFactory.createFixtureBuilder(getClass().getSimpleName()); myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(testFixtureBuilder.getFixture()); final String dataPath = PluginPathManager.getPluginHomePath("testng") + "/testData"; myFixture.setTestDataPath(dataPath); final JavaModuleFixtureBuilder builder = testFixtureBuilder.addModule(JavaModuleFixtureBuilder.class); builder.addContentRoot(myFixture.getTempDirPath()).addSourceRoot(""); // builder.addContentRoot(dataPath); builder.setMockJdkLevel(JavaModuleFixtureBuilder.MockJdkLevel.jdk15); myFixture.setUp(); final JavaPsiFacade facade = JavaPsiFacade.getInstance(myFixture.getProject()); myLanguageLevel = LanguageLevelProjectExtension.getInstance(facade.getProject()).getLanguageLevel(); LanguageLevelProjectExtension.getInstance(facade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_5); } catch (Exception e) { throw new RuntimeException(e); } } }); }
setUp
17,301
void () { try { final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory(); final TestFixtureBuilder<IdeaProjectTestFixture> testFixtureBuilder = fixtureFactory.createFixtureBuilder(getClass().getSimpleName()); myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(testFixtureBuilder.getFixture()); final String dataPath = PluginPathManager.getPluginHomePath("testng") + "/testData"; myFixture.setTestDataPath(dataPath); final JavaModuleFixtureBuilder builder = testFixtureBuilder.addModule(JavaModuleFixtureBuilder.class); builder.addContentRoot(myFixture.getTempDirPath()).addSourceRoot(""); // builder.addContentRoot(dataPath); builder.setMockJdkLevel(JavaModuleFixtureBuilder.MockJdkLevel.jdk15); myFixture.setUp(); final JavaPsiFacade facade = JavaPsiFacade.getInstance(myFixture.getProject()); myLanguageLevel = LanguageLevelProjectExtension.getInstance(facade.getProject()).getLanguageLevel(); LanguageLevelProjectExtension.getInstance(facade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_5); } catch (Exception e) { throw new RuntimeException(e); } }
run
17,302
void () { UIUtil.invokeAndWaitIfNeeded(() -> { try { LanguageLevelProjectExtension.getInstance(myFixture.getProject()).setLanguageLevel(myLanguageLevel); myFixture.tearDown(); myFixture = null; } catch (Exception e) { throw new RuntimeException(e); } }); }
tearDown
17,303
Object[][] () { return new String[][]{new String[]{"InsideReference"}, new String[]{"AfterReference"}}; }
data
17,304
void (final String testName) { UIUtil.invokeAndWaitIfNeeded(() -> { try { IntentionAction resultAction = null; final List<IntentionAction> actions = myFixture.getAvailableIntentions("intention/testNGJar" + "/" + testName + ".java"); for (IntentionAction action : actions) { if (Comparing.strEqual(action.getText(), "Add testng.jar to classpath")) { resultAction = action; break; } } Assert.assertNotNull(resultAction); } catch (Exception e) { throw new RuntimeException(e); } }); }
doTest
17,305
PsiElement () { final PsiClass cls = TestNGUtil.getProviderClass(getElement(), PsiUtil.getTopLevelClass(getElement())); if (cls != null) { PsiMethod[] methods = cls.getAllMethods(); @NonNls String val = getValue(); for (PsiMethod method : methods) { PsiAnnotation dataProviderAnnotation = AnnotationUtil.findAnnotation(method, DataProvider.class.getName()); if (dataProviderAnnotation != null) { final PsiAnnotationMemberValue dataProviderMethodName = dataProviderAnnotation.findDeclaredAttributeValue("name"); if (dataProviderMethodName != null && val.equals(StringUtil.unquoteString(dataProviderMethodName.getText()))) { return method; } if (val.equals(method.getName())) { return method; } } } } return null; }
resolve
17,306
String () { return "TestNG"; }
getName
17,307
Icon () { return TestngIcons.TestNG; }
getIcon
17,308
String () { return "org.testng.annotations.Test"; }
getMarkerClassFQName
17,309
ExternalLibraryDescriptor () { return TestNGExternalLibraryResolver.TESTNG_DESCRIPTOR; }
getFrameworkLibraryDescriptor
17,310
String () { return null; }
getDefaultSuperClass
17,311
boolean (PsiClass clazz, boolean canBePotential) { if (canBePotential) return isUnderTestSources(clazz); return TestNGUtil.isTestNGClass(clazz); }
isTestClass
17,312
PsiMethod (@NotNull PsiClass clazz) { for (PsiMethod each : clazz.getMethods()) { if (AnnotationUtil.isAnnotated(each, "org.testng.annotations.BeforeMethod", 0)) return each; } return null; }
findSetUpMethod
17,313
PsiMethod (@NotNull PsiClass clazz) { for (PsiMethod each : clazz.getMethods()) { if (AnnotationUtil.isAnnotated(each, "org.testng.annotations.BeforeClass", 0)) return each; } return null; }
findBeforeClassMethod
17,314
PsiMethod (@NotNull PsiClass clazz) { for (PsiMethod each : clazz.getMethods()) { if (AnnotationUtil.isAnnotated(each, "org.testng.annotations.AfterMethod", 0)) return each; } return null; }
findTearDownMethod
17,315
PsiMethod (@NotNull PsiClass clazz) { for (PsiMethod each : clazz.getMethods()) { if (AnnotationUtil.isAnnotated(each, "org.testng.annotations.AfterClass", 0)) return each; } return null; }
findAfterClassMethod
17,316
FileTemplateDescriptor () { return new FileTemplateDescriptor("TestNG Test Class.java"); }
getTestClassFileTemplateDescriptor
17,317
FileTemplateDescriptor () { return new FileTemplateDescriptor("TestNG SetUp Method.java"); }
getSetUpMethodFileTemplateDescriptor
17,318
FileTemplateDescriptor () { return new FileTemplateDescriptor("TestNG BeforeClass Method.java"); }
getBeforeClassMethodFileTemplateDescriptor
17,319
FileTemplateDescriptor () { return new FileTemplateDescriptor("TestNG TearDown Method.java"); }
getTearDownMethodFileTemplateDescriptor
17,320
FileTemplateDescriptor () { return new FileTemplateDescriptor("TestNG AfterClass Method.java"); }
getAfterClassMethodFileTemplateDescriptor
17,321
FileTemplateDescriptor () { return new FileTemplateDescriptor("TestNG Test Method.java"); }
getTestMethodFileTemplateDescriptor
17,322
FileTemplateDescriptor () { return new FileTemplateDescriptor("TestNG Parameters Method.java"); }
getParametersMethodFileTemplateDescriptor
17,323
boolean (PsiElement element, boolean checkAbstract) { return element instanceof PsiMethod && isFrameworkAvailable(element) && TestNGUtil.hasTest((PsiModifierListOwner)element); }
isTestMethod
17,324
boolean (ConfigurationType type) { return type instanceof TestNGConfigurationType; }
isMyConfigurationType
17,325
void (@NotNull PsiReferenceRegistrar registrar) { registrar.registerReferenceProvider( getElementPattern(GROUP_CLASSES, "groups"), new PsiReferenceProvider() { @Override public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement element, @NotNull final ProcessingContext context) { return new GroupReference[]{new GroupReference(element.getProject(), (PsiLiteral)element)}; } }); registrar.registerReferenceProvider( getElementPattern(GROUP_CLASSES, "dependsOnMethods"), new PsiReferenceProvider() { @Override public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement element, @NotNull final ProcessingContext context) { return new MethodReference[]{new MethodReference((PsiLiteral)element)}; } }); registrar.registerReferenceProvider( getElementPattern(GROUP_CLASSES, "dependsOnGroups"), new PsiReferenceProvider() { @Override public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement element, @NotNull final ProcessingContext context) { return new GroupReference[]{new GroupReference(element.getProject(), (PsiLiteral)element)}; } }); registrar.registerReferenceProvider( getElementPattern(List.of(ORG_TESTNG_ANNOTATIONS_TEST, ORG_TESTNG_ANNOTATIONS_FACTORY), "dataProvider"), new PsiReferenceProvider() { @Override public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement element, @NotNull final ProcessingContext context) { return new DataProviderReference[]{new DataProviderReference((PsiLiteral)element)}; } }); }
registerReferenceProviders
17,326
PsiElement () { @NonNls String val = getValue(); final String methodName = StringUtil.getShortName(val); PsiClass cls = getDependsClass(val); if (cls != null) { PsiMethod[] methods = cls.findMethodsByName(methodName, true); for (PsiMethod method : methods) { if (TestNGUtil.hasTest(method, false) || TestNGUtil.hasConfig(method)) { return method; } } } return null; }
resolve
17,327
PsiClass (String val) { final String className = StringUtil.getPackageName(val); final PsiLiteral element = getElement(); return StringUtil.isEmpty(className) ? PsiUtil.getTopLevelClass(element) : JavaPsiFacade.getInstance(element.getProject()).findClass(className, element.getResolveScope()); }
getDependsClass
17,328
PsiElement () { return null; }
resolve
17,329
boolean (Object element, PsiElement context) { PsiNameValuePair pair = PsiTreeUtil.getParentOfType(context, PsiNameValuePair.class, false, PsiMember.class, PsiStatement.class, PsiCall.class); if (null == pair) return false; if (!myParameterName.equals(pair.getName())) return false; PsiAnnotation annotation = PsiTreeUtil.getParentOfType(pair, PsiAnnotation.class); if (annotation == null) return false; return ContainerUtil.find(myAnnotationFqns, fqn -> annotation.hasQualifiedName(fqn)) != null; }
isAcceptable
17,330
boolean (Class hintClass) { return PsiLiteral.class.isAssignableFrom(hintClass); }
isClassAcceptable
17,331
void (@NotNull PsiReferenceRegistrar registrar) { registrar.registerReferenceProvider(Holder.ourTestClassPattern, new JavaClassReferenceProvider()); registrar.registerReferenceProvider(Holder.ourListenerClassPattern, new JavaClassReferenceProvider()); final JavaClassReferenceProvider methodSelectorProvider = new JavaClassReferenceProvider(); methodSelectorProvider.setOption(JavaClassReferenceProvider.EXTEND_CLASS_NAMES, new String[]{"org.testng.IMethodSelector"}); registrar.registerReferenceProvider(Holder.ourMethodSelectorPattern, methodSelectorProvider); registrar.registerReferenceProvider(Holder.ourSuiteFilePattern, new PathListReferenceProvider(){ @Override protected boolean disableNonSlashedPaths() { return false; } }); }
registerReferenceProviders
17,332
boolean () { return false; }
disableNonSlashedPaths
17,333
void (@NotNull MethodReferencesSearch.SearchParameters queryParameters, @NotNull Processor<? super PsiReference> consumer) { final PsiMethod method = queryParameters.getMethod(); final PsiAnnotation annotation = AnnotationUtil.findAnnotation(method, DataProvider.class.getName()); if (annotation == null) return; final PsiAnnotationMemberValue dataProviderMethodName = annotation.findDeclaredAttributeValue("name"); if (dataProviderMethodName != null) { final String providerName = StringUtil.unquoteString(dataProviderMethodName.getText()); queryParameters.getOptimizer().searchWord(providerName, queryParameters.getEffectiveSearchScope(), UsageSearchContext.IN_STRINGS, true, method); } }
processQuery
17,334
boolean () { String testngJarPath = PathUtil.getJarPathForClass(Test.class); String version = JarUtil.getJarAttribute(new File(testngJarPath), Attributes.Name.IMPLEMENTATION_VERSION); return version != null && StringUtil.compareVersionNumbers(version, "5.12") <= 0; }
hasDocTagsSupport
17,335
boolean (PsiModifierListOwner element) { return hasConfig(element, CONFIG_ANNOTATIONS_FQN); }
hasConfig
17,336
boolean (PsiModifierListOwner element, String[] configAnnotationsFqn) { if (element instanceof PsiClass) { for (PsiMethod method : ((PsiClass)element).getAllMethods()) { if (isConfigMethod(method, configAnnotationsFqn)) return true; } } else { if (!(element instanceof PsiMethod)) return false; return isConfigMethod((PsiMethod)element, configAnnotationsFqn); } return false; }
hasConfig
17,337
boolean (PsiMethod method, String[] configAnnotationsFqn) { for (String fqn : configAnnotationsFqn) { if (AnnotationUtil.isAnnotated(method, fqn, 0)) return true; } if (hasDocTagsSupport) { final PsiDocComment comment = method.getDocComment(); if (comment != null) { for (String javadocTag : CONFIG_JAVADOC_TAGS) { if (comment.findTagByName(javadocTag) != null) return true; } } } return false; }
isConfigMethod
17,338
String (PsiMethod method) { if (method != null) { for (String fqn : CONFIG_ANNOTATIONS_FQN) { if (AnnotationUtil.isAnnotated(method, fqn, 0)) return fqn; } } return null; }
getConfigAnnotation
17,339
boolean (PsiAnnotation annotation) { String qName = annotation.getQualifiedName(); if (qName != null) { if (qName.equals(TEST_ANNOTATION_FQN)) return true; for (String qn : CONFIG_ANNOTATIONS_FQN) { if (qName.equals(qn)) return true; } for (String qn : CONFIG_ANNOTATIONS_FQN) { if (qName.equals(qn)) return true; } } return false; }
isTestNGAnnotation
17,340
boolean (PsiModifierListOwner element) { return CachedValuesManager.getCachedValue(element, () -> CachedValueProvider.Result.create(hasTest(element, true), PsiModificationTracker.MODIFICATION_COUNT)); }
hasTest
17,341
boolean (PsiModifierListOwner element, boolean checkDisabled) { return hasTest(element, true, checkDisabled, hasDocTagsSupport); }
hasTest
17,342
boolean (PsiModifierListOwner element, boolean checkHierarchy, boolean checkDisabled, boolean checkJavadoc) { final PsiClass aClass; if (element instanceof PsiClass) { aClass = ((PsiClass)element); } else if (element instanceof PsiMethod) { aClass = ((PsiMethod)element).getContainingClass(); } else { aClass = null; } if (aClass == null || !PsiClassUtil.isRunnableClass(aClass, true, false)) { return false; } //LanguageLevel effectiveLanguageLevel = element.getManager().getEffectiveLanguageLevel(); //boolean is15 = effectiveLanguageLevel != LanguageLevel.JDK_1_4 && effectiveLanguageLevel != LanguageLevel.JDK_1_3; boolean hasAnnotation = AnnotationUtil.isAnnotated(element, TEST_ANNOTATION_FQN, checkHierarchy ? AnnotationUtil.CHECK_HIERARCHY : 0); if (hasAnnotation) { if (checkDisabled) { PsiAnnotation annotation = AnnotationUtil.findAnnotation(element, true, TEST_ANNOTATION_FQN); if (annotation != null) { if (isDisabled(annotation)) return false; } } return true; } if (checkJavadoc && getTextJavaDoc((PsiDocCommentOwner)element) != null) return true; //now we check all methods for the test annotation if (element instanceof PsiClass) { PsiClass psiClass = (PsiClass) element; for (PsiMethod method : psiClass.getAllMethods()) { PsiAnnotation annotation = AnnotationUtil.findAnnotation(method, true, TEST_ANNOTATION_FQN); if (annotation != null) { if (checkDisabled) { if (isDisabled(annotation)) continue; } return true; } if (AnnotationUtil.isAnnotated(method, FACTORY_ANNOTATION_FQN, 0)) return true; if (checkJavadoc && getTextJavaDoc(method) != null) return true; } return false; } else { //even if it has a global test, we ignore non-public and static methods if (!element.hasModifierProperty(PsiModifier.PUBLIC) || element.hasModifierProperty(PsiModifier.STATIC)) { return false; } //if it's a method, we check if the class it's in has a global @Test annotation PsiClass psiClass = ((PsiMethod)element).getContainingClass(); if (psiClass != null) { final PsiAnnotation annotation = checkHierarchy ? AnnotationUtil.findAnnotationInHierarchy(psiClass, Collections.singleton(TEST_ANNOTATION_FQN)) : AnnotationUtil.findAnnotation(psiClass, true, TEST_ANNOTATION_FQN); if (annotation != null) { if (checkDisabled && isDisabled(annotation)) return false; return !hasConfig(element); } else if (checkJavadoc && getTextJavaDoc(psiClass) != null) return true; } } return false; }
hasTest
17,343
boolean (PsiAnnotation annotation) { PsiNameValuePair attribute = AnnotationUtil.findDeclaredAttribute(annotation, "enabled"); final PsiAnnotationMemberValue attributeValue = attribute != null ? attribute.getDetachedValue() : null; return attributeValue != null && attributeValue.textMatches("false"); }
isDisabled
17,344
PsiDocTag (@NotNull final PsiDocCommentOwner element) { final PsiDocComment docComment = element.getDocComment(); if (docComment != null) { return docComment.findTagByName("testng.test"); } return null; }
getTextJavaDoc
17,345
boolean (PsiAnnotation annotation, String parameter, Set<String> values) { final PsiAnnotationMemberValue attributeValue = annotation.findDeclaredAttributeValue(parameter); if (attributeValue != null) { Collection<String> matches = extractValuesFromParameter(attributeValue); for (String s : matches) { if (values.contains(s)) { return true; } } } return false; }
isAnnotatedWithParameter
17,346
Set<String> (String parameter, PsiClass... classes) { Map<String, Collection<String>> results = new HashMap<>(); final HashSet<String> set = new HashSet<>(); results.put(parameter, set); collectAnnotationValues(results, null, classes); return set; }
getAnnotationValues
17,347
void (final Map<String, Collection<String>> results, PsiMethod[] psiMethods, PsiClass... classes) { final Set<String> test = new HashSet<>(1); test.add(TEST_ANNOTATION_FQN); ContainerUtil.addAll(test, CONFIG_ANNOTATIONS_FQN); if (psiMethods != null) { for (final PsiMethod psiMethod : psiMethods) { ApplicationManager.getApplication().runReadAction( () -> appendAnnotationAttributeValues(results, AnnotationUtil.findAnnotation(psiMethod, test), psiMethod) ); } } else { for (final PsiClass psiClass : classes) { ApplicationManager.getApplication().runReadAction(() -> { if (psiClass != null && hasTest(psiClass)) { appendAnnotationAttributeValues(results, AnnotationUtil.findAnnotation(psiClass, test), psiClass); PsiMethod[] methods = psiClass.getMethods(); for (PsiMethod method : methods) { if (method != null) { appendAnnotationAttributeValues(results, AnnotationUtil.findAnnotation(method, test), method); } } } }); } } }
collectAnnotationValues
17,348
void (final Map<String, Collection<String>> results, final PsiAnnotation annotation, final PsiDocCommentOwner commentOwner) { for (String parameter : results.keySet()) { final Collection<String> values = results.get(parameter); if (annotation != null) { final PsiAnnotationMemberValue value = annotation.findDeclaredAttributeValue(parameter); if (value != null) { values.addAll(extractValuesFromParameter(value)); } } else { values.addAll(extractAnnotationValuesFromJavaDoc(getTextJavaDoc(commentOwner), parameter)); } } }
appendAnnotationAttributeValues
17,349
Collection<String> (PsiDocTag tag, String parameter) { if (tag == null) return Collections.emptyList(); Collection<String> results = new ArrayList<>(); Matcher matcher = Pattern.compile("@testng.test(?:.*)" + parameter + "\\s*=\\s*\"(.*?)\".*").matcher(tag.getText()); if (matcher.matches()) { String[] groups = matcher.group(1).split("[,\\s]"); for (String group : groups) { final String trimmed = group.trim(); if (!trimmed.isEmpty()) { results.add(trimmed); } } } return results; }
extractAnnotationValuesFromJavaDoc
17,350
Collection<String> (PsiAnnotationMemberValue value) { return JBIterable.from(AnnotationUtil.arrayAttributeValues(value)) .filter(PsiLiteralExpression.class) .map(PsiLiteralExpression::getValue) .filter(String.class) .toList(); }
extractValuesFromParameter
17,351
PsiAnnotation[] (PsiElement element) { return SyntaxTraverser.psiTraverser(element).filter(PsiAnnotation.class) .filter(anno -> { String name = anno.getQualifiedName(); return name != null && name.startsWith("org.testng.annotations"); }).toArray(PsiAnnotation.EMPTY_ARRAY); }
getTestNGAnnotations
17,352
boolean (PsiClass psiClass) { return hasTest(psiClass); }
isTestNGClass
17,353
boolean (PsiElement psiElement) { final Project project = psiElement.getProject(); final PsiManager manager = PsiManager.getInstance(project); if (JavaPsiFacade.getInstance(manager.getProject()).findClass(TestNG.class.getName(), psiElement.getResolveScope()) == null) { if (!ApplicationManager.getApplication().isUnitTestMode()) { if (Messages.showOkCancelDialog(psiElement.getProject(), TestngBundle.message("testng.util.will.be.added.to.module.classpath"), TestngBundle.message("testng.util.unable.to.convert"), Messages.getWarningIcon()) != Messages.OK) { return false; } } final Module module = ModuleUtilCore.findModuleForPsiElement(psiElement); if (module == null) return false; String url = VfsUtil.getUrlForLibraryRoot(new File(PathUtil.getJarPathForClass(Assert.class))); ModuleRootModificationUtil.addModuleLibrary(module, url); } return true; }
checkTestNGInClasspath
17,354
boolean (PsiClass psiClass) { if (psiClass != null) { for (PsiMethod method : psiClass.getMethods()) { if (containsJunitAnnotations(method)) { return true; } } } return false; }
containsJunitAnnotations
17,355
boolean (PsiMethod method) { return method != null && AnnotationUtil.isAnnotated(method, JUNIT_ANNOTATIONS, 0); }
containsJunitAnnotations
17,356
boolean (PsiClass psiClass) { return InheritanceUtil.isInheritor(psiClass, "junit.framework.TestCase"); }
inheritsJUnitTestCase
17,357
boolean (@NotNull PsiClass psiClass) { final Project project = psiClass.getProject(); final PsiClass aListenerClass = JavaPsiFacade.getInstance(project) .findClass(ITestNGListener.class.getName(), GlobalSearchScope.allScope(project)); return aListenerClass != null && psiClass.isInheritor(aListenerClass, true); }
inheritsITestListener
17,358
boolean (final VirtualFile virtualFile) { if (virtualFile.isInLocalFileSystem() && virtualFile.isValid()) { String extension = virtualFile.getExtension(); if ("xml".equalsIgnoreCase(extension)) { final String result = NanoXmlUtil.parseHeader(virtualFile).getRootTagLocalName(); if (result != null && result.equals(SUITE_TAG_NAME)) { return true; } } else if ("yaml".equals(extension)) { return true; } } return false; }
isTestngSuiteFile
17,359
PsiClass (final PsiElement element, final PsiClass topLevelClass) { final PsiAnnotation annotation = PsiTreeUtil.getParentOfType(element, PsiAnnotation.class); if (annotation != null) { final PsiAnnotationMemberValue value = annotation.findDeclaredAttributeValue("dataProviderClass"); if (value instanceof PsiClassObjectAccessExpression) { final PsiTypeElement operand = ((PsiClassObjectAccessExpression)value).getOperand(); final PsiClass psiClass = PsiUtil.resolveClassInType(operand.getType()); if (psiClass != null) { return psiClass; } } } return topLevelClass; }
getProviderClass
17,360
Version (@NotNull Project project, @NotNull Module module) { return CachedValuesManager.getManager(project).getCachedValue(module, () -> { String version = null; JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project); PsiClass aClass = psiFacade.findClass("org.testng.internal.Version", GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module)); if (aClass != null) { PsiField versionField = aClass.findFieldByName("VERSION", false); if (versionField != null) { PsiExpression initializer = versionField.getInitializer(); if (initializer instanceof PsiLiteralExpression) { Object eval = ((PsiLiteralExpression)initializer).getValue(); if (eval instanceof String) { version = (String)eval; } } else { version = String.valueOf(Integer.MAX_VALUE); } } } if (version == null) return null; return CachedValueProvider.Result.createSingleDependency(Version.parseVersion(version), ProjectRootManager.getInstance(module.getProject())); }); }
detectVersion
17,361
ConfigurationFactory () { return TestNGConfigurationType.getInstance(); }
getConfigurationFactory
17,362
boolean () { return true; }
isEditableInDumbMode
17,363
RunConfiguration (@NotNull Project project) { return new TestNGConfiguration(project, this); }
createTemplateConfiguration
17,364
String () { return "testNg"; }
getTag
17,365
String () { return "reference.dialogs.rundebug.TestNG"; }
getHelpTopic
17,366
TestNGConfigurationType () { return ConfigurationTypeUtil.findConfigurationType(TestNGConfigurationType.class); }
getInstance
17,367
boolean (RunConfiguration runConfiguration, Location location) { TestNGConfiguration config = (TestNGConfiguration)runConfiguration; TestData testObject = config.getPersistantData(); if (testObject == null) { return false; } final PsiElement element = location.getPsiElement(); final TestNGTestObject testNGTestObject = TestNGTestObject.fromConfig(config); if (testNGTestObject.isConfiguredByElement(element)) { final Module configurationModule = config.getConfigurationModule().getModule(); if (Comparing.equal(location.getModule(), configurationModule)) return true; final Module predefinedModule = ((TestNGConfiguration)RunManager.getInstance(location.getProject()).getConfigurationTemplate(getConfigurationFactories()[0]) .getConfiguration()).getConfigurationModule().getModule(); return Comparing.equal(predefinedModule, configurationModule); } else { return false; } }
isConfigurationByLocation
17,368
DependencyScope (@NotNull Library library) { VirtualFile[] files = library.getFiles(OrderRootType.CLASSES); if (files.length == 1 && LibraryUtil.isClassAvailableInLibrary(files, "org.testng.annotations.Test")) { return DependencyScope.TEST; } return null; }
getDefaultDependencyScope
17,369
void (@NotNull ConfigurationFromContext configuration, @NotNull ConfigurationContext fromContext, @NotNull Runnable performRunnable) { myDelegate.onFirstRun(configuration, fromContext, performRunnable); }
onFirstRun
17,370
boolean (@NotNull TestNGConfiguration configuration, @NotNull ConfigurationContext context, @NotNull Ref<PsiElement> sourceElement) { return myDelegate.setupConfigurationFromContext(configuration, context, sourceElement); }
setupConfigurationFromContext
17,371
boolean (String type, ConfigurationContext context) { return myDelegate.isApplicableTestType(type, context); }
isApplicableTestType
17,372
ConfigurationFactory () { return TestNGConfigurationType.getInstance(); }
getConfigurationFactory
17,373
boolean (@NotNull TestNGConfiguration configuration, @NotNull ConfigurationContext context, @NotNull Ref<PsiElement> sourceElement) { return super.setupConfigurationFromContext(configuration, context, sourceElement); }
setupConfigurationFromContext
17,374
boolean (String type, ConfigurationContext context) { return TestType.CLASS.getType().equals(type) || TestType.METHOD.getType().equals(type); }
isApplicableTestType
17,375
boolean (@NotNull TestNGConfiguration configuration, @NotNull ConfigurationContext context, @NotNull Ref<PsiElement> sourceElement) { final LinkedHashSet<String> classes = new LinkedHashSet<>(); final PsiElement element = checkPatterns(context, classes); if (element == null) { return false; } if (JavaPsiFacade.getInstance(context.getProject()) .findClass(TestNGUtil.TEST_ANNOTATION_FQN, element.getResolveScope()) == null) { return false; } sourceElement.set(element); final TestData data = configuration.getPersistantData(); data.setPatterns(classes); data.TEST_OBJECT = TestType.PATTERN.getType(); data.setScope(setupPackageConfiguration(context, configuration, data.getScope())); configuration.setGeneratedName(); setupConfigurationParamName(configuration, context.getLocation()); return true; }
setupConfigurationFromContext
17,376
Module (TestNGConfiguration configuration, Module contextModule) { final Set<String> patterns = configuration.data.getPatterns(); return findModule(configuration, contextModule, patterns); }
findModule
17,377
boolean (@NotNull TestNGConfiguration testNGConfiguration, @NotNull ConfigurationContext context) { if (!isApplicableTestType(testNGConfiguration.getTestType(), context)) return false; if (differentParamSet(testNGConfiguration, context.getLocation())) return false; return isConfiguredFromContext(context, testNGConfiguration.getPersistantData().getPatterns()); }
isConfigurationFromContext
17,378
boolean (String type, ConfigurationContext context) { return TestType.PATTERN.getType().equals(type); }
isApplicableTestType
17,379
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; }
setupConfigurationFromContext
17,380
boolean (String type, ConfigurationContext context) { return TestType.SUITE.getType().equals(type); }
isApplicableTestType
17,381
ConfigurationFactory () { return TestNGConfigurationType.getInstance(); }
getConfigurationFactory
17,382
String (String str) { return StringUtil.trimEnd(StringUtil.trimStart(str, "["), "]"); }
getInvocationNumber
17,383
void () { if (!myClasses.isEmpty()) { composeTestSuiteFromClasses(); } else if (TestType.SUITE.getType().equals(myData.TEST_OBJECT)) { // Running a suite, make a local copy of the suite and apply our custom parameters to it and run that instead. try { composeTestSuiteFromXml(); } catch (CantRunException e) { logCantRunException(e); } } try { FileUtil.writeToFile(myTempFile, "end".getBytes(StandardCharsets.UTF_8), true); } catch (IOException e) { LOG.error(e); } }
onFound
17,384
void (ExecutionException e) { try { final String message = "CantRunException" + e.getMessage() + "\n"; FileUtil.writeToFile(myTempFile, message.getBytes(StandardCharsets.UTF_8)); } catch (IOException e1) { LOG.error(e1); } }
logCantRunException
17,385
void () { Map<String, Map<String, List<String>>> map = new LinkedHashMap<>(); final boolean findTestMethodsForClass = shouldSearchForTestMethods(); for (final Map.Entry<PsiClass, Map<PsiMethod, List<String>>> entry : myClasses.entrySet()) { final Map<PsiMethod, List<String>> depMethods = entry.getValue(); LinkedHashMap<String, List<String>> methods = new LinkedHashMap<>(); for (Map.Entry<PsiMethod, List<String>> method : depMethods.entrySet()) { methods.put(method.getKey().getName(), method.getValue()); } if (findTestMethodsForClass && depMethods.isEmpty()) { for (PsiMethod method : entry.getKey().getMethods()) { if (TestNGUtil.hasTest(method)) { methods.put(method.getName(), Collections.emptyList()); } } } final String className = ReadAction.compute(() -> ClassUtil.getJVMClassName(entry.getKey())); if (className != null) { map.put(className, methods); } } // We have groups we wish to limit to. Collection<String> groupNames = myConfig.calculateGroupNames(); Map<String, String> testParams = buildTestParameters(); int logLevel = 1; try { final Properties properties = new Properties(); properties.load(new ByteArrayInputStream(myConfig.getVMParameters().getBytes(StandardCharsets.UTF_8))); final String verbose = properties.getProperty("-Dtestng.verbose"); if (verbose != null) { logLevel = Integer.parseInt(verbose); } } catch (Exception ignore) { //not a number } File xmlFile; if (groupNames != null) { final LinkedHashMap<String, Collection<String>> methodNames = new LinkedHashMap<>(); for (Map.Entry<String, Map<String, List<String>>> entry : map.entrySet()) { methodNames.put(entry.getKey(), entry.getValue().keySet()); } LaunchSuite suite = SuiteGenerator.createSuite(myProject.getName(), null, methodNames, groupNames, testParams, "jdk", logLevel); xmlFile = suite.save(new File(PathManager.getSystemPath())); } else { XmlSuite suite = new XmlSuite(); suite.setParameters(testParams); String programParameters = myConfig.getProgramParameters(); if (programParameters != null && ParametersListUtil.parse(programParameters).contains("-threadcount")) { suite.setThreadCount(-1); } xmlFile = TestNGXmlSuiteHelper.writeSuite(map, myProject.getName(), PathManager.getSystemPath(), new TestNGXmlSuiteHelper.Logger() { @Override public void log(Throwable e) { LOG.error(e); } }, requireToDowngradeToHttp(), suite); } String path = xmlFile.getAbsolutePath() + "\n"; try { FileUtil.writeToFile(myTempFile, path.getBytes(StandardCharsets.UTF_8), true); } catch (IOException e) { LOG.error(e); } }
composeTestSuiteFromClasses
17,386
void (Throwable e) { LOG.error(e); }
log
17,387
boolean () { GlobalSearchScope searchScope = ObjectUtils.notNull(myConfig.getSearchScope(), GlobalSearchScope.allScope(myProject)); PsiClass testMarker = JavaPsiFacade.getInstance(myProject).findClass(TestNGUtil.TEST_ANNOTATION_FQN, searchScope); String version = getVersion(testMarker); return version == null || StringUtil.compareVersionNumbers(version, "7.0.0") < 0; }
requireToDowngradeToHttp
17,388
String (PsiClass classFromCommon) { VirtualFile virtualFile = PsiUtilCore.getVirtualFile(classFromCommon); if (virtualFile != null) { ProjectFileIndex index = ProjectFileIndex.getInstance(classFromCommon.getProject()); VirtualFile root = index.getClassRootForFile(virtualFile); if (root != null) { VirtualFileSystem fileSystem = root.getFileSystem(); if (fileSystem instanceof JarFileSystem jarFs) { VirtualFile localFile = jarFs.getLocalByEntry(root); if (localFile != null) { String name = localFile.getNameWithoutExtension(); if (name.startsWith("testng-")) { return StringUtil.trimStart(name, "testng-"); } } } } } return null; }
getVersion
17,389
boolean () { for (Map<PsiMethod, List<String>> methods : myClasses.values()) { if (!methods.isEmpty()) { return true; } } return false; }
shouldSearchForTestMethods
17,390
boolean (@NotNull TestNGConfiguration configuration, @NotNull ConfigurationContext context, @NotNull Ref<PsiElement> sourceElement) { final PsiElement element = context.getPsiLocation(); PsiPackage aPackage = AbstractJavaTestConfigurationProducer.checkPackage(element); if (aPackage == null) { return false; } final Location location = context.getLocation(); if (location == null) { return false; } if (!LocationUtil.isJarAttached(location, aPackage, TestNGUtil.TEST_ANNOTATION_FQN)) { return false; } final TestData data = configuration.data; data.PACKAGE_NAME = aPackage.getQualifiedName(); data.TEST_OBJECT = TestType.PACKAGE.getType(); data.setScope(setupPackageConfiguration(context, configuration, data.getScope())); configuration.setGeneratedName(); sourceElement.set(aPackage); return true; }
setupConfigurationFromContext
17,391
boolean (String type, ConfigurationContext context) { return TestType.PACKAGE.getType().equals(type); }
isApplicableTestType
17,392
void (final String qualifiedName) { final boolean generatedName = isGeneratedName(); data.PACKAGE_NAME = qualifiedName; if (generatedName) setGeneratedName(); }
setName
17,393
PsiPackage () { final String qualifiedName = data.getPackageName(); return qualifiedName != null ? JavaPsiFacade.getInstance(getProject()).findPackage(qualifiedName) : null; }
getPsiElement
17,394
void (final PsiPackage psiPackage) { setName(psiPackage.getQualifiedName()); }
setPsiElement
17,395
void (final String qualifiedName) { final boolean generatedName = isGeneratedName(); data.MAIN_CLASS_NAME = qualifiedName; if (generatedName) setGeneratedName(); }
setName
17,396
PsiClass () { final String qualifiedName = data.getMainClassName(); return qualifiedName != null ? JavaPsiFacade.getInstance(getProject()).findClass(qualifiedName, GlobalSearchScope.allScope(project)) : null; }
getPsiElement
17,397
void (@NotNull PsiClass psiClass) { setName(psiClass.getQualifiedName()); }
setPsiElement
17,398
RemoteConnectionCreator () { return null; }
getRemoteConnectionCreator
17,399
TestNGRunnableState (@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) { final TestData data = getPersistantData(); if (data.TEST_OBJECT.equals(TestType.SOURCE.getType()) || data.getChangeList() != null) { return new TestNGTestDiscoveryRunnableState(env, this); } return new TestNGRunnableState(env, this); }
getState