private static void checkNoUnresolvedReferences(@NotNull final JetFile file) {
    AnalyzeExhaust exhaust = AnalyzerFacadeWithCache.analyzeFileWithCache(file);
    for (Diagnostic diagnostic : exhaust.getBindingContext().getDiagnostics()) {
      if (Errors.UNRESOLVED_REFERENCE_DIAGNOSTICS.contains(diagnostic.getFactory())) {
        List<TextRange> textRanges = diagnostic.getTextRanges();
        String diagnosticText = DefaultErrorMessages.RENDERER.render(diagnostic);
        if (diagnostic.getPsiFile() == file) {
          fail(
              diagnostic.getFactory().getName()
                  + ": "
                  + diagnosticText
                  + " "
                  + DiagnosticUtils.atLocation(file, textRanges.get(0)));
        }
      }
    }
    DebugInfoUtil.markDebugAnnotations(
        file,
        exhaust.getBindingContext(),
        new DebugInfoUtil.DebugInfoReporter() {
          @Override
          public void reportElementWithErrorType(@NotNull JetReferenceExpression expression) {
            // do nothing
          }

          @Override
          public void reportMissingUnresolved(@NotNull JetReferenceExpression expression) {
            // this may happen if incorrect psi transformations are done
            fail(
                expression.getText()
                    + " is unresolved but not marked "
                    + DiagnosticUtils.atLocation(file, expression.getTextRange()));
          }

          @Override
          public void reportUnresolvedWithTarget(
              @NotNull JetReferenceExpression expression, @NotNull String target) {
            // do nothing
          }
        });
  }