Skip to content

Commit

Permalink
fix: export entry functions named
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Mar 2, 2021
1 parent 5e1bec2 commit 24f272a
Showing 1 changed file with 117 additions and 115 deletions.
232 changes: 117 additions & 115 deletions lib/autocomplete-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,132 +5,134 @@ import PathsProvider from "./paths-provider"
import { CompositeDisposable } from "atom"
import { OptionScopes } from "./config/option-scopes"

export default {
config: Config,
subscriptions: null,
let subscriptions = new CompositeDisposable()
let _provider
let _statusBar
let _statusBarInterval
let _statusBarTile
let _statusBarElement
let _displayStatusBarItemOnConsumption

activate: function () {
this.subscriptions = new CompositeDisposable()
this.subscriptions.add(
atom.commands.add("atom-workspace", {
"autocomplete-paths:rebuild-cache": () => {
this._provider.rebuildCache()
},
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 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) => {
subscriptions.add(
atom.config.observe(scopeOption, (value) => {
if (!_provider) return
_provider.reloadScopes()
})
)
})
}

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()
})
)
})
},
export function deactivate() {
if (_statusBarInterval) {
clearInterval(_statusBarInterval)
}
subscriptions.dispose()
if (_provider) {
_provider.dispose(true)
_provider = null
}
if (_statusBarTile) {
_statusBarTile.destroy()
_statusBarTile = null
}
}

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
*/
export function consumeStatusBar(statusBar) {
_statusBar = statusBar
if (_displayStatusBarItemOnConsumption) {
_displayStatusBarTile()
}
}

/**
* 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
*/
function _displayStatusBarTile() {
if (!_statusBar) {
_displayStatusBarItemOnConsumption = true
return
}
if (_statusBarTile) return

/**
* Displays the status bar tile
*/
_displayStatusBarTile() {
if (!this._statusBar) {
this._displayStatusBarItemOnConsumption = true
_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
}
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
}
}
_statusBarInterval = setInterval(() => {
const fileCount = _provider.fileCount
if (fileCount > 0) {
_statusBarElement.innerHTML = `Rebuilding paths cache... ${fileCount} files`
}
this._statusBarInterval = setInterval(() => {
const fileCount = this._provider.fileCount
if (fileCount > 0) {
this._statusBarElement.innerHTML = `Rebuilding paths cache... ${fileCount} files`
}
}, 500)
},
}, 500)
}

/**
* Hides the status bar tile
*/
_hideStatusBarTile() {
if (this._statusBarInterval) {
clearInterval(this._statusBarInterval)
}
this._statusBarTile && this._statusBarTile.destroy()
this._statusBarTile = null
this._statusBarElement = null
},
/**
* Hides the status bar tile
*/
function _hideStatusBarTile() {
if (_statusBarInterval) {
clearInterval(_statusBarInterval)
}
_statusBarTile && _statusBarTile.destroy()
_statusBarTile = null
_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
},
export function getProvider() {
if (!_provider) {
_provider = new PathsProvider()
_provider.on("rebuild-cache", () => {
_displayStatusBarTile()
})
_provider.on("rebuild-cache-done", () => {
_hideStatusBarTile()
})
_provider.rebuildCache()
}
return _provider
}

0 comments on commit 24f272a

Please sign in to comment.