<commit_before>"use babel"

export { config } from "./config"
import PathsProvider from "./paths-provider"
import { CompositeDisposable } from "atom"
import { OptionScopes } from "./config/option-scopes"

export default {
  config: Config,
  subscriptions: null,

  activate: function () {
    this.subscriptions = new CompositeDisposable()
    this.subscriptions.add(
      atom.commands.add("atom-workspace", {
        "autocomplete-paths:rebuild-cache": () => {
          this._provider.rebuildCache()
        },
      })
    )

    const cacheOptions = [
      "core.ignoredNames",
      "core.excludeVcsIgnoredPaths",
      "autocomplete-paths.ignoreSubmodules",
      "autocomplete-paths.ignoredNames",
      "autocomplete-paths.ignoredPatterns",
      "autocomplete-paths.maxFileCount",
    ]
    cacheOptions.forEach((cacheOption) => {
      this.subscriptions.add(
        atom.config.observe(cacheOption, (value) => {
          if (!this._provider) return
          this._provider._pathsCache.updateConfig()
          this._provider.rebuildCache()
        })
      )
    })

    const scopeOptions = ["autocomplete-paths.scopes"]
    for (let key in OptionScopes) {
      scopeOptions.push(`autocomplete-paths.${key}`)
    }
    scopeOptions.forEach((scopeOption) => {
      this.subscriptions.add(
        atom.config.observe(scopeOption, (value) => {
          if (!this._provider) return
          this._provider.reloadScopes()
        })
      )
    })
  },

  deactivate: function () {
    if (this._statusBarInterval) {
      clearInterval(this._statusBarInterval)
    }
    this.subscriptions.dispose()
    if (this._provider) {
      this._provider.dispose(true)
      this._provider = null
    }
    if (this._statusBarTile) {
      this._statusBarTile.destroy()
      this._statusBarTile = null
    }
  },

  /**
   * Invoked when the status bar becomes available
   * @param  {StatusBar} statusBar
   */
  consumeStatusBar: function (statusBar) {
    this._statusBar = statusBar
    if (this._displayStatusBarItemOnConsumption) {
      this._displayStatusBarTile()
    }
  },

  /**
   * Displays the status bar tile
   */
  _displayStatusBarTile() {
    if (!this._statusBar) {
      this._displayStatusBarItemOnConsumption = true
      return
    }
    if (this._statusBarTile) return

    this._statusBarElement = document.createElement("autocomplete-paths-status-bar")
    this._statusBarElement.innerHTML = "Rebuilding paths cache..."
    this._statusBarTile = this._statusBar.addRightTile({
      item: this._statusBarElement,
      priority: 100,
    })
    if (!this._provider) {
      // TODO check why we need this check
      this.getProvider()
      if (!this._provider) {
        return
      }
    }
    this._statusBarInterval = setInterval(() => {
      const fileCount = this._provider.fileCount
      if (fileCount > 0) {
        this._statusBarElement.innerHTML = `Rebuilding paths cache... ${fileCount} files`
      }
    }, 500)
  },

  /**
   * Hides the status bar tile
   */
  _hideStatusBarTile() {
    if (this._statusBarInterval) {
      clearInterval(this._statusBarInterval)
    }
    this._statusBarTile && this._statusBarTile.destroy()
    this._statusBarTile = null
    this._statusBarElement = null
  },

  getProvider: function () {
    if (!this._provider) {
      this._provider = new PathsProvider()
      this._provider.on("rebuild-cache", () => {
        this._displayStatusBarTile()
      })
      this._provider.on("rebuild-cache-done", () => {
        this._hideStatusBarTile()
      })
      this._provider.rebuildCache()
    }
    return this._provider
  },
}<commit_msg>fix: export entry functions named<commit_after>"use babel"

export { config } from "./config"
import PathsProvider from "./paths-provider"
import { CompositeDisposable } from "atom"
import { OptionScopes } from "./config/option-scopes"

let subscriptions = new CompositeDisposable()
let _provider
let _statusBar
let _statusBarInterval
let _statusBarTile
let _statusBarElement
let _displayStatusBarItemOnConsumption

export function activate() {
  subscriptions.add(
    atom.commands.add("atom-workspace", {
      "autocomplete-paths:rebuild-cache": () => {
        _provider.rebuildCache()
      },
    })
  )

  const cacheOptions = [
    "core.ignoredNames",
    "core.excludeVcsIgnoredPaths",
    "autocomplete-paths.ignoreSubmodules",
    "autocomplete-paths.ignoredNames",
    "autocomplete-paths.ignoredPatterns",
    "autocomplete-paths.maxFileCount",
  ]
  cacheOptions.forEach((cacheOption) => {
    subscriptions.add(
      atom.config.observe(cacheOption, (value) => {
        if (!_provider) return
        _provider._pathsCache.updateConfig()
        _provider.rebuildCache()
      })
    )
  })

  const scopeOptions = ["autocomplete-paths.scopes"]
  for (let key in OptionScopes) {
    scopeOptions.push(`autocomplete-paths.${key}`)
  }
  scopeOptions.forEach((scopeOption) => {
    subscriptions.add(
      atom.config.observe(scopeOption, (value) => {
        if (!_provider) return
        _provider.reloadScopes()
      })
    )
  })
}

export function deactivate() {
  if (_statusBarInterval) {
    clearInterval(_statusBarInterval)
  }
  subscriptions.dispose()
  if (_provider) {
    _provider.dispose(true)
    _provider = null
  }
  if (_statusBarTile) {
    _statusBarTile.destroy()
    _statusBarTile = null
  }
}

/**
 * Invoked when the status bar becomes available
 * @param  {StatusBar} statusBar
 */
export function consumeStatusBar(statusBar) {
  _statusBar = statusBar
  if (_displayStatusBarItemOnConsumption) {
    _displayStatusBarTile()
  }
}

/**
 * Displays the status bar tile
 */
function _displayStatusBarTile() {
  if (!_statusBar) {
    _displayStatusBarItemOnConsumption = true
    return
  }
  if (_statusBarTile) return

  _statusBarElement = document.createElement("autocomplete-paths-status-bar")
  _statusBarElement.innerHTML = "Rebuilding paths cache..."
  _statusBarTile = _statusBar.addRightTile({
    item: _statusBarElement,
    priority: 100,
  })
  if (!_provider) {
    // TODO check why we need this check
    getProvider()
    if (!_provider) {
      return
    }
  }
  _statusBarInterval = setInterval(() => {
    const fileCount = _provider.fileCount
    if (fileCount > 0) {
      _statusBarElement.innerHTML = `Rebuilding paths cache... ${fileCount} files`
    }
  }, 500)
}

/**
 * Hides the status bar tile
 */
function _hideStatusBarTile() {
  if (_statusBarInterval) {
    clearInterval(_statusBarInterval)
  }
  _statusBarTile && _statusBarTile.destroy()
  _statusBarTile = null
  _statusBarElement = null
}

export function getProvider() {
  if (!_provider) {
    _provider = new PathsProvider()
    _provider.on("rebuild-cache", () => {
      _displayStatusBarTile()
    })
    _provider.on("rebuild-cache-done", () => {
      _hideStatusBarTile()
    })
    _provider.rebuildCache()
  }
  return _provider
}
{'fraction_non_alphanumeric': 0.12015615962984384, 'fraction_numerical': 0.0020242914979757085, 'mean_word_length': 2.966169724770642, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 21, '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': '1649950', 'n_tokens_mistral': 2128, 'n_tokens_neox': 2073, 'n_words': 384}