<commit_before>import * as Path from 'path'
import { pathExists } from 'fs-extra'
import { IFoundEditor } from './found-editor'
import { assertNever } from '../fatal-error'
import appPath from 'app-path'
import { parseEnumValue } from '../enum'

export enum ExternalEditor {
  Atom = 'Atom',
  MacVim = 'MacVim',
  VSCode = 'Visual Studio Code',
  VSCodeInsiders = 'Visual Studio Code (Insiders)',
  VSCodium = 'VSCodium',
  SublimeText = 'Sublime Text',
  BBEdit = 'BBEdit',
  PhpStorm = 'PhpStorm',
  PyCharm = 'PyCharm',
  RubyMine = 'RubyMine',
  TextMate = 'TextMate',
  Brackets = 'Brackets',
  WebStorm = 'WebStorm',
  Typora = 'Typora',
  CodeRunner = 'CodeRunner',
  SlickEdit = 'SlickEdit',
  IntelliJ = 'IntelliJ',
  Xcode = 'Xcode',
  GoLand = 'GoLand',
  AndroidStudio = 'Android Studio',
  Rider = 'Rider',
  Nova = 'Nova',
}

export function parse(label: string): ExternalEditor | null {
  return parseEnumValue(ExternalEditor, label) ?? null
}

function getBundleIdentifiers(editor: ExternalEditor): ReadonlyArray<string> {
  switch (editor) {
    case ExternalEditor.Atom:
      return ['com.github.atom']
    case ExternalEditor.MacVim:
      return ['org.vim.MacVim']
    case ExternalEditor.VSCode:
      return ['com.microsoft.VSCode']
    case ExternalEditor.VSCodeInsiders:
      return ['com.microsoft.VSCodeInsiders']
    case ExternalEditor.VSCodium:
      return ['com.visualstudio.code.oss']
    case ExternalEditor.SublimeText:
      return ['com.sublimetext.3']
    case ExternalEditor.BBEdit:
      return ['com.barebones.bbedit']
    case ExternalEditor.PhpStorm:
      return ['com.jetbrains.PhpStorm']
    case ExternalEditor.PyCharm:
      return ['com.jetbrains.PyCharm']
    case ExternalEditor.RubyMine:
      return ['com.jetbrains.RubyMine']
    case ExternalEditor.IntelliJ:
      return ['com.jetbrains.intellij']
    case ExternalEditor.TextMate:
      return ['com.macromates.TextMate']
    case ExternalEditor.Brackets:<commit_msg>Add detection of Sublime Text 4 and 2 as editor on macOS.<commit_after>import * as Path from 'path'
import { pathExists } from 'fs-extra'
import { IFoundEditor } from './found-editor'
import { assertNever } from '../fatal-error'
import appPath from 'app-path'
import { parseEnumValue } from '../enum'

export enum ExternalEditor {
  Atom = 'Atom',
  MacVim = 'MacVim',
  VSCode = 'Visual Studio Code',
  VSCodeInsiders = 'Visual Studio Code (Insiders)',
  VSCodium = 'VSCodium',
  SublimeText = 'Sublime Text',
  BBEdit = 'BBEdit',
  PhpStorm = 'PhpStorm',
  PyCharm = 'PyCharm',
  RubyMine = 'RubyMine',
  TextMate = 'TextMate',
  Brackets = 'Brackets',
  WebStorm = 'WebStorm',
  Typora = 'Typora',
  CodeRunner = 'CodeRunner',
  SlickEdit = 'SlickEdit',
  IntelliJ = 'IntelliJ',
  Xcode = 'Xcode',
  GoLand = 'GoLand',
  AndroidStudio = 'Android Studio',
  Rider = 'Rider',
  Nova = 'Nova',
}

export function parse(label: string): ExternalEditor | null {
  return parseEnumValue(ExternalEditor, label) ?? null
}

function getBundleIdentifiers(editor: ExternalEditor): ReadonlyArray<string> {
  switch (editor) {
    case ExternalEditor.Atom:
      return ['com.github.atom']
    case ExternalEditor.MacVim:
      return ['org.vim.MacVim']
    case ExternalEditor.VSCode:
      return ['com.microsoft.VSCode']
    case ExternalEditor.VSCodeInsiders:
      return ['com.microsoft.VSCodeInsiders']
    case ExternalEditor.VSCodium:
      return ['com.visualstudio.code.oss']
    case ExternalEditor.SublimeText:
      return ['com.sublimetext.4', 'com.sublimetext.3', 'com.sublimetext.2']
    case ExternalEditor.BBEdit:
      return ['com.barebones.bbedit']
    case ExternalEditor.PhpStorm:
      return ['com.jetbrains.PhpStorm']
    case ExternalEditor.PyCharm:
      return ['com.jetbrains.PyCharm']
    case ExternalEditor.RubyMine:
      return ['com.jetbrains.RubyMine']
    case ExternalEditor.IntelliJ:
      return ['com.jetbrains.intellij']
    case ExternalEditor.TextMate:
      return ['com.macromates.TextMate']
    case ExternalEditor.Brackets:
{'fraction_non_alphanumeric': 0.12605250123823675, 'fraction_numerical': 0.0014858841010401188, 'mean_word_length': 3.837125748502994, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3686060', 'n_tokens_mistral': 1421, 'n_tokens_neox': 1350, 'n_words': 302}