private static void checkMethodReference(PsiMethodReferenceExpression expression,
                                           InspectionManager inspectionManager,
                                           List<? super ProblemDescriptor> problems,
                                           boolean isOnTheFly) {
    final PsiTypeElement qualifierTypeElement = expression.getQualifierType();
    if (qualifierTypeElement != null) {
      final PsiType psiType = qualifierTypeElement.getType();
      if (psiType instanceof PsiClassType && !((PsiClassType)psiType).isRaw()) {
        PsiClass aClass = ((PsiClassType)psiType).resolve();
        if (aClass == null) return;
        final JavaResolveResult result = expression.advancedResolve(false);
        final PsiElement element = result.getElement();
        if (element instanceof PsiTypeParameterListOwner) {
          PsiMethod method = element instanceof PsiMethod ? (PsiMethod)element : null;
          if (PsiDiamondTypeUtil.areTypeArgumentsRedundant(((PsiClassType)psiType).getParameters(), expression, false, method, aClass.getTypeParameters())) {
            final PsiJavaCodeReferenceElement referenceElement = qualifierTypeElement.getInnermostComponentReferenceElement();
            LOG.assertTrue(referenceElement != null, qualifierTypeElement);
            final PsiReferenceParameterList parameterList = referenceElement.getParameterList();
            LOG.assertTrue(parameterList != null);
            for (PsiTypeElement typeElement : parameterList.getTypeParameterElements()) {
              if (typeElement.getAnnotations().length > 0) {
                return;
              }
            }
            final ProblemDescriptor descriptor = inspectionManager.createProblemDescriptor(parameterList, JavaAnalysisBundle
              .message("inspection.redundant.type.problem.descriptor"), ourQuickFixAction, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly);
            problems.add(descriptor);
          }
        }
      }
    }
    else {
      PsiType[] typeArguments = expression.getTypeParameters();
      PsiReferenceParameterList parameterList = expression.getParameterList();
      if (typeArguments.length > 0 && parameterList != null) {
        PsiElement resolve = expression.resolve();
        if (resolve == null) return;
        PsiTypeParameter[] typeParameters = resolve instanceof PsiClass ? PsiTypeParameter.EMPTY_ARRAY : ((PsiMethod)resolve).getTypeParameters();
        if (typeParameters.length == 0 ||
            typeParameters.length == typeArguments.length &&
            PsiDiamondTypeUtil.areTypeArgumentsRedundant(typeArguments, expression, false, (PsiMethod)resolve, typeParameters)) {
          String key = typeParameters.length == 0 ? "inspection.redundant.type.no.generics.method.reference.problem.descriptor"
                                                  : "inspection.redundant.type.problem.descriptor";
          final ProblemDescriptor descriptor =
            inspectionManager.createProblemDescriptor(parameterList,
                                                      JavaAnalysisBundle.message(key),
                                                      new MyQuickFixAction(), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly);
          problems.add(descriptor);
        }
      }
    }
  }
private static void checkMethodReference(PsiMethodReferenceExpression expression,
                                           InspectionManager inspectionManager,
                                           List<? super ProblemDescriptor> problems,
                                           boolean isOnTheFly)