primaryProjectNature function

RunFolder? primaryProjectNature(
  1. List<RunFolder> natures
)

The nature that decides a project's language and defaults when it has several: Flutter, Dart, then TypeScript, JavaScript, Python, Java, Go, Rust, C++, C. Null when the folder has no project nature.

Implementation

RunFolder? primaryProjectNature(List<RunFolder> natures) {
  for (final pick in <bool Function(RunFolder)>[
    (n) => n is FlutterProjectFolder,
    (n) => n is DartProjectFolder,
    (n) => n is TypeScriptFolder,
    (n) => n is JavaScriptFolder,
    (n) => n is PythonFolder,
    (n) => n is JavaFolder,
    (n) => n is GoFolder,
    (n) => n is RustFolder,
    (n) => n is ScalaFolder,
    (n) => n is CppFolder,
    (n) => n is CFolder,
  ]) {
    for (final n in natures) {
      if (pick(n)) return n;
    }
  }
  return null;
}