@Nullable
  protected PsiFile createFile(
      @NotNull Project project, @NotNull VirtualFile file, @NotNull FileType fileType) {
    if (fileType.isBinary() || file.isSpecialFile()) {
      return new PsiBinaryFileImpl((PsiManagerImpl) getManager(), this);
    }
    if (!isTooLarge(file)) {
      final PsiFile psiFile = createFile(getBaseLanguage());
      if (psiFile != null) return psiFile;
    }

    return new PsiPlainTextFileImpl(this);
  }
  private PsiFile createFile() {
    try {
      final VirtualFile vFile = getVirtualFile();
      if (vFile.isDirectory()) return null;
      if (isIgnored()) return null;

      final Project project = myManager.getProject();
      if (isPhysical()) { // check directories consistency
        final VirtualFile parent = vFile.getParent();
        if (parent == null) return null;
        final PsiDirectory psiDir = getManager().findDirectory(parent);
        if (psiDir == null) return null;
      }

      FileType fileType = vFile.getFileType();
      PsiFile file = null;
      if (fileType.isBinary() || vFile.isSpecialFile()) {
        // TODO check why ClsFileImpl doesn't created automatically with create method
        file = new ClsFileImpl((PsiManagerImpl) getManager(), this);
        // file = new PsiBinaryFileImpl((PsiManagerImpl) getManager(), this);
      } else {
        if (!isTooLarge(vFile)) {
          final PsiFile psiFile = createFile(getBaseLanguage());
          if (psiFile != null) file = psiFile;
        } else {
          file = new PsiPlainTextFileImpl(this);
        }
      }
      return file;
    } catch (ProcessCanceledException e) {
      e.printStackTrace();
      throw e;

    } catch (Throwable e) {
      e.printStackTrace();
      LOG.error(e);
      return null;
    }
  }