void (PsiMethod method) { method.accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitExpressionStatement(@NotNull PsiExpressionStatement statement) { PsiExpression expression = statement.getExpression(); if (expression instanceof PsiMethodCallExpression methodCall) { if (methodCall.getArgumentList().getExpressionCount() == 1) { PsiMethod resolved = methodCall.resolveMethod(); if (resolved != null && "junit.framework.TestCase".equals(resolved.getContainingClass().getQualifiedName()) && "TestCase".equals(resolved.getName())) { try { statement.delete(); } catch (IncorrectOperationException e) { LOG.error(e); } } } } } }); }