private static boolean isEnabled(Editor editor) {
    boolean isEnabled = myIsEnabledInTests && ApplicationManager.getApplication().isUnitTestMode()
                        || Registry.is("editor.reformat.on.typing");

    if (!isEnabled) {
      return false;
    }

    Project project = editor.getProject();
    Language language = null;
    if (project != null) {
      PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
      if (file != null) {
        language = file.getLanguage();
      }
    }

    return language == JavaLanguage.INSTANCE;
  }
private static boolean isEnabled(Editor editor)