nuclide-commons-atom
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -9,4 +9,9 @@ 'use strict'; | ||
// Default to "nuclide", but only for unit tests. | ||
let packageName = null; | ||
/** | ||
* Sets the root package name. | ||
* This gets automatically called from FeatureLoader. | ||
*/ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
@@ -27,8 +32,2 @@ * All rights reserved. | ||
let packageName = atom.inSpecMode() ? 'nuclide' : null; | ||
/** | ||
* Sets the root package name. | ||
* This gets automatically called from FeatureLoader. | ||
*/ | ||
function setPackageName(name) { | ||
@@ -39,6 +38,5 @@ packageName = name; | ||
function formatKeyPath(keyPath) { | ||
if (!packageName) { | ||
throw new Error('feature-config must be used with FeatureLoader.'); | ||
if (packageName == null) { | ||
return keyPath; | ||
} | ||
return `${packageName}.${keyPath}`; | ||
@@ -135,6 +133,5 @@ } | ||
function isFeatureDisabled(name) { | ||
if (!packageName) { | ||
throw new Error('feature-config must be used with FeatureLoader.'); | ||
if (packageName == null) { | ||
return atom.packages.isPackageDisabled(name); | ||
} | ||
return atom.packages.isPackageDisabled(packageName) || !atom.config.get(`${packageName}.use.${name}`); | ||
@@ -141,0 +138,0 @@ } |
{ | ||
"name": "nuclide-commons-atom", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Common Nuclide node modules (for use with Atom only).", | ||
@@ -16,3 +16,3 @@ "license": "SEE LICENSE IN LICENSE", | ||
"log4js": "1.1.1", | ||
"nuclide-commons": "0.1.5", | ||
"nuclide-commons": "0.1.6", | ||
"rxjs": "5.3.1", | ||
@@ -19,0 +19,0 @@ "semver": "5.3.0", |
@@ -18,9 +18,14 @@ 'use strict'; | ||
constructor() { | ||
this._providers = new Set(); | ||
this._providers = []; | ||
} | ||
addProvider(provider) { | ||
this._providers.add(provider); | ||
const index = this._providers.findIndex(p => provider.priority > p.priority); | ||
if (index === -1) { | ||
this._providers.push(provider); | ||
} else { | ||
this._providers.splice(index, 0, provider); | ||
} | ||
return new (_UniversalDisposable || _load_UniversalDisposable()).default(() => { | ||
this._providers.delete(provider); | ||
this.removeProvider(provider); | ||
}); | ||
@@ -30,3 +35,6 @@ } | ||
removeProvider(provider) { | ||
this._providers.delete(provider); | ||
const index = this._providers.indexOf(provider); | ||
if (index !== -1) { | ||
this._providers.splice(index, 1); | ||
} | ||
} | ||
@@ -39,14 +47,23 @@ | ||
getAllProvidersForEditor(editor) { | ||
const grammar = editor.getGrammar().scopeName; | ||
return this.findAllProviders(grammar); | ||
} | ||
findProvider(grammar) { | ||
let bestProvider = null; | ||
let bestPriority = Number.NEGATIVE_INFINITY; | ||
for (const provider of this.findAllProviders(grammar)) { | ||
return provider; | ||
} | ||
return null; | ||
} | ||
/** | ||
* Iterates over all providers matching the grammar, in priority order. | ||
*/ | ||
*findAllProviders(grammar) { | ||
for (const provider of this._providers) { | ||
if (provider.grammarScopes.indexOf(grammar) !== -1) { | ||
if (provider.priority > bestPriority) { | ||
bestProvider = provider; | ||
bestPriority = provider.priority; | ||
} | ||
if (provider.grammarScopes == null || provider.grammarScopes.indexOf(grammar) !== -1) { | ||
yield provider; | ||
} | ||
} | ||
return bestProvider; | ||
} | ||
@@ -53,0 +70,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
160726
1974
+ Addednuclide-commons@0.1.6(transitive)
- Removednuclide-commons@0.1.5(transitive)
Updatednuclide-commons@0.1.6