@Override
    public void documentChanged(@NotNull DocumentEvent e) {
      Document document = e.getDocument();
      if (!ApplicationManager.getApplication().hasWriteAction(ExternalChangeAction.ExternalDocumentChange.class)) {
        myUnsavedDocuments.add(document);
      }
      Runnable currentCommand = CommandProcessor.getInstance().getCurrentCommand();
      Project project = currentCommand == null ? null : CommandProcessor.getInstance().getCurrentCommandProject();
      VirtualFile virtualFile = getFile(document);
      if (project == null) {
        project = virtualFile == null ? null : ProjectUtil.guessProjectForFile(virtualFile);
      }
      CodeStyleSettings settings = project != null && virtualFile != null
                                   ? CodeStyle.getSettings(project, virtualFile)
                                   : CodeStyle.getProjectOrDefaultSettings(project);
      String lineSeparator = settings.getLineSeparator();
      document.putUserData(LINE_SEPARATOR_KEY, lineSeparator);

      // avoid documents piling up during batch processing
      if (areTooManyDocumentsInTheQueue(myUnsavedDocuments)) {
        saveAllDocumentsLater();
      }
    }
@Override
    public void documentChanged(@NotNull DocumentEvent e)