private static @Nullable Charset guessFileTypeCharset(@Nullable Project project,
                                                        byte @NotNull [] content,
                                                        @NotNull FileType fileType,
                                                        @NotNull @NonNls @SystemIndependent String lightFilePath) {
    LightVirtualFileBase file = new MyBinaryLightVirtualFile(lightFilePath, fileType, content);
    if (project != null) {
      // pass Project to the EncodingManagerImpl to delegate to the EncodingProjectManagerImpl when needed
      try (AccessToken ignored = ProjectLocator.withPreferredProject(file, project)) {
        return CharsetToolkit.forName(fileType.getCharset(file, content));
      }
    }
    else {
      return CharsetToolkit.forName(fileType.getCharset(file, content));
    }
  }
private static @Nullable Charset guessFileTypeCharset(@Nullable Project project,
                                                        byte @NotNull [] content,
                                                        @NotNull FileType fileType,
                                                        @NotNull @NonNls @SystemIndependent String lightFilePath)