public void testRunningAllInPackage() throws IOException, ExecutionException { Module module1 = getModule1(); GlobalSearchScope module1AndLibraries = GlobalSearchScope.moduleWithLibrariesScope(module1); PsiClass testCase = findClass(TestCase.class.getName(), module1AndLibraries); PsiClass psiClass = findTestA(module1); PsiClass psiClass2 = findTestA(getModule2()); PsiClass derivedTest = findClass(module1, "test1.DerivedTest"); PsiClass baseTestCase = findClass("junit.framework.ThirdPartyClass", module1AndLibraries); PsiClass testB = findClass(getModule3(), "test1.TestB"); assertNotNull(testCase); assertNotNull(derivedTest); assertNotNull(psiClass); assertTrue(psiClass.isInheritor(testCase, false)); assertEquals(baseTestCase, derivedTest.getSuperClass()); assertTrue(baseTestCase.isInheritor(testCase, true)); assertTrue(derivedTest.isInheritor(testCase, true)); PsiPackage psiPackage = JUnitUtil.getContainingPackage(psiClass); JUnitConfiguration configuration = createConfiguration(psiPackage, module1); JavaParameters parameters = checkCanRun(configuration); List<String> lines = extractAllInPackageTests(parameters, psiPackage); Assertion.compareUnordered( new Object[] { "", psiClass.getQualifiedName(), psiClass2.getQualifiedName(), derivedTest.getQualifiedName(), RT_INNER_TEST_NAME, testB.getQualifiedName() }, lines); }
@Nullable private ProblemDescriptor createDescription( @NotNull PsiTypeCastExpression cast, @NotNull InspectionManager manager, boolean onTheFly) { PsiExpression operand = cast.getOperand(); PsiTypeElement castType = cast.getCastType(); if (operand == null || castType == null) return null; PsiElement parent = cast.getParent(); while (parent instanceof PsiParenthesizedExpression) { parent = parent.getParent(); } if (parent instanceof PsiReferenceExpression) { if (IGNORE_ANNOTATED_METHODS) { final PsiElement gParent = parent.getParent(); if (gParent instanceof PsiMethodCallExpression) { final PsiMethod psiMethod = ((PsiMethodCallExpression) gParent).resolveMethod(); if (psiMethod != null && NullableNotNullManager.isNotNull(psiMethod)) { final PsiClass superClass = PsiUtil.resolveClassInType(operand.getType()); final PsiClass containingClass = psiMethod.getContainingClass(); if (containingClass != null && superClass != null && containingClass.isInheritor(superClass, true)) { for (PsiMethod method : psiMethod.findSuperMethods(superClass)) { if (NullableNotNullManager.isNullable(method)) { return null; } } } } } } } else if (parent instanceof PsiExpressionList) { final PsiElement gParent = parent.getParent(); if (gParent instanceof PsiMethodCallExpression && IGNORE_SUSPICIOUS_METHOD_CALLS) { final String message = SuspiciousCollectionsMethodCallsInspection.getSuspiciousMethodCallMessage( (PsiMethodCallExpression) gParent, operand.getType(), true, new ArrayList<PsiMethod>(), new IntArrayList()); if (message != null) { return null; } } } String message = InspectionsBundle.message( "inspection.redundant.cast.problem.descriptor", "<code>" + operand.getText() + "</code>", "<code>#ref</code> #loc"); return manager.createProblemDescriptor( castType, message, myQuickFixAction, ProblemHighlightType.LIKE_UNUSED_SYMBOL, onTheFly); }