private static boolean isAutoPopup(@NotNull Editor editor, @NotNull PsiFile file, char charTyped) {
    final int offset = editor.getCaretModel().getOffset() - 1;
    if (offset >= 0) {
      PsiElement element;
      Language language;
      if (file instanceof PsiFileWithOneLanguage) {
        element = null;
        language = file.getLanguage();
      }
      else {
        element = file.findElementAt(offset);
        if (element == null) {
          return false;
        }
        language = element.getLanguage();
      }

      for (CompletionContributor contributor : CompletionContributor.forLanguageHonorDumbness(language, file.getProject())) {
        if (element == null) {
          element = file.findElementAt(offset);
          if (element == null) {
            return false;
          }
        }
        if (contributor.invokeAutoPopup(element, charTyped)) {
          LOG.debug(contributor + " requested completion autopopup when typing '" + charTyped + "'");
          return true;
        }
      }
    }
    return false;
  }
private static boolean isAutoPopup(@NotNull Editor editor, @NotNull PsiFile file, char charTyped)