From 55f3004e0c2136271071649912fc4d0c6e063525 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sun, 4 Oct 2020 19:46:46 -0500 Subject: [PATCH] feat: use ProviderRegistry from atom-ide-base --- lib/main.js | 4 ++-- lib/providerRegistry.js | 35 ----------------------------------- 2 files changed, 2 insertions(+), 37 deletions(-) delete mode 100644 lib/providerRegistry.js diff --git a/lib/main.js b/lib/main.js index 2a45a63..bf664e4 100644 --- a/lib/main.js +++ b/lib/main.js @@ -3,10 +3,10 @@ import { CompositeDisposable } from "atom" import { install as installPackageDependencies } from "atom-package-deps" import { goToDefinition } from "./goToDefinition" -import createProviderRegistry from "./providerRegistry" +import { ProviderRegistry } from "atom-ide-base/commons-atom/ProviderRegistry" import { ClickProvider } from "./clickProvider" -const providerRegistry = createProviderRegistry() +const providerRegistry = new ProviderRegistry() // const clickProvider = new ClickProvider({ providerRegistry, }) diff --git a/lib/providerRegistry.js b/lib/providerRegistry.js deleted file mode 100644 index b7f0699..0000000 --- a/lib/providerRegistry.js +++ /dev/null @@ -1,35 +0,0 @@ -"use babel" - -import { Disposable } from "atom" - -function providerRegistry() { - let providers = [] - - function addProvider(provider) { - const index = providers.findIndex((p) => provider.priority > p.priority) - if (index === -1) { - providers.push(provider) - } else { - providers.splice(index, 0, provider) - } - - return new Disposable(() => removeProvider(provider)) - } - - function removeProvider(provider) { - const index = providers.indexOf(provider) - if (index !== -1) { - providers.splice(index, 1) - } - } - - function getProviderForEditor(editor) { - const grammar = editor.getGrammar().scopeName - - return providers.find((provider) => !provider.grammarScopes || provider.grammarScopes.indexOf(grammar) !== -1) - } - - return { addProvider, getProviderForEditor } -} - -export default providerRegistry