private static ImportClassFix computeImportFix(@NotNull PsiFile file, int startOffset, int endOffset) {
    ApplicationManager.getApplication().assertIsNonDispatchThread();
    List<PsiElement> elements = CollectHighlightsUtil.getElementsInRange(file, startOffset, endOffset);
    for (PsiElement element : elements) {
      if (element instanceof PsiJavaCodeReferenceElement ref) {
        ImportClassFix fix = new ImportClassFix(ref);
        if (fix.isAvailable(file.getProject(), null, file)) {
          fix.surviveOnPSIModifications(); // make possible to apply several of these actions at once
          return fix;
        }
      }
    }

    return null;
  }
private static ImportClassFix computeImportFix(@NotNull PsiFile file, int startOffset, int endOffset)