void (RefElement refElement) { if (refElement instanceof RefMethodImpl) { if (refElement.getPsiElement() instanceof PsiMethod method) { final PsiCodeBlock body = method.getBody(); if (body == null) return; final Collection<PsiClassType> exceptionTypes = getUnhandledExceptions(body, method, method.getContainingClass()); for (final PsiClassType exceptionType : exceptionTypes) { ((RefMethodImpl)refElement).updateThrowsList(exceptionType); } } } else if (refElement instanceof RefFunctionalExpression) { PsiElement expression = refElement.getPsiElement(); Collection<PsiClassType> exceptionTypes = null; PsiMethod method = null; if (expression instanceof PsiLambdaExpression) { PsiElement body = ((PsiLambdaExpression)expression).getBody(); exceptionTypes = body != null ? ExceptionUtil.collectUnhandledExceptions(body, expression, false) : Collections.emptyList(); method = LambdaUtil.getFunctionalInterfaceMethod(expression); } else if (expression instanceof PsiMethodReferenceExpression) { PsiMethod resolved = ObjectUtils.tryCast(((PsiMethodReferenceExpression)expression).resolve(), PsiMethod.class); if (resolved != null) { PsiClassType[] types = resolved.getThrowsList().getReferencedTypes(); exceptionTypes = types.length == 0 ? Collections.emptyList() : Arrays.asList(types); } method = LambdaUtil.getFunctionalInterfaceMethod(expression); } if (method == null || exceptionTypes == null) return; RefElement refMethod = myRefManager.getReference(method); if (refMethod == null) return; Collection<PsiClassType> finalExceptionTypes = exceptionTypes; myRefManager.executeTask(() -> { refMethod.initializeIfNeeded(); for (PsiClassType exceptionType : finalExceptionTypes) { ((RefMethodImpl)refMethod).updateThrowsList(exceptionType); } }); } }