static HighlightInfo.Builder checkReturnStatementType(@NotNull PsiReturnStatement statement, @NotNull PsiElement parent) {
    if (parent instanceof PsiCodeFragment || parent instanceof PsiLambdaExpression) {
      return null;
    }
    PsiMethod method = tryCast(parent, PsiMethod.class);
    String description;
    HighlightInfo.Builder errorResult;
    if (method == null && !(parent instanceof ServerPageFile)) {
      description = JavaErrorBundle.message("return.outside.method");
      errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(description);
    }
    else {
      PsiType returnType = method != null ? method.getReturnType() : null/*JSP page returns void*/;
      boolean isMethodVoid = returnType == null || PsiTypes.voidType().equals(returnType);
      PsiExpression returnValue = statement.getReturnValue();
      if (returnValue != null) {
        PsiType valueType = RefactoringChangeUtil.getTypeByExpression(returnValue);
        if (isMethodVoid) {
          boolean constructor = method != null && method.isConstructor();
          if (constructor) {
            PsiClass containingClass = method.getContainingClass();
            if (containingClass != null && !method.getName().equals(containingClass.getName())) {
              return null;
            }
          }
          description = JavaErrorBundle.message(constructor ? "return.from.constructor" : "return.from.void.method");
          errorResult =
            HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(description);
          if (method != null && valueType != null && method.getBody() != null) {
            IntentionAction action1 = getFixFactory().createDeleteReturnFix(method, statement);
            errorResult.registerFix(action1, null, null, null, null);
            IntentionAction action = getFixFactory().createMethodReturnFix(method, valueType, true);
            errorResult.registerFix(action, null, null, null, null);
          }
        }
        else {
          TextRange textRange = statement.getTextRange();
          errorResult = checkAssignability(returnType, valueType, returnValue, textRange, returnValue.getStartOffsetInParent());
          if (errorResult != null && valueType != null) {
            if (!PsiTypes.voidType().equals(valueType)) {
              IntentionAction action = getFixFactory().createMethodReturnFix(method, valueType, true);
              errorResult.registerFix(action, null, null, null, null);
            }
            HighlightFixUtil.registerChangeParameterClassFix(returnType, valueType, errorResult);
          }
        }
      }
      else if (!isMethodVoid && !PsiTreeUtil.hasErrorElements(statement)) {
        description = JavaErrorBundle.message("missing.return.value");
        errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(description)
          .navigationShift(PsiKeyword.RETURN.length());
        IntentionAction action = getFixFactory().createMethodReturnFix(method, PsiTypes.voidType(), true);
        errorResult.registerFix(action, null, null, null, null);
      }
      else {
        errorResult = null;
      }
    }
    return errorResult;
  }
static HighlightInfo.Builder checkReturnStatementType(@NotNull PsiReturnStatement statement, @NotNull PsiElement parent)