Syntax calls into atom.config for scoped properties

This commit is contained in:
Ben Ogle
2014-10-01 17:05:04 -07:00
parent f61a7d0c62
commit dd05c6cec1
2 changed files with 17 additions and 34 deletions

View File

@@ -708,10 +708,22 @@ class Config
.join(' ')
@scopedSettingsStore.getPropertyValue(scopeChain, keyPath)
# TODO: figure out how to remove this. Only language mode uses it for one thing.
settingsForScopeDescriptor: (scopeDescriptor, keyPath) ->
scopeChain = scopeDescriptor
.map (scope) ->
scope = ".#{scope}" unless scope[0] is '.'
scope
.join(' ')
@scopedSettingsStore.getProperties(scopeChain, keyPath)
removeScopedSettingsForName: (name) ->
@scopedSettingsStore.removeProperties(name)
@scopedSettingsStore.removeProperties("#{name}+default")
clearScopedSettings: ->
@scopedSettingsStore = new ScopedPropertyStore
# Base schema enforcers. These will coerce raw input into the specified type,
# and will throw an error when the value cannot be coerced. Throwing the error
# will indicate that the value should not be set.

View File

@@ -28,7 +28,6 @@ class Syntax extends GrammarRegistry
constructor: ->
super(maxTokensPerLine: 100)
@propertyStore = new ScopedPropertyStore
serialize: ->
{deserializer: @constructor.name, @grammarOverridesByPath}
@@ -41,44 +40,16 @@ class Syntax extends GrammarRegistry
@propertyStore.propertySets
addProperties: (args...) ->
name = args.shift() if args.length > 2
[selector, properties] = args
propertiesBySelector = {}
propertiesBySelector[selector] = properties
@propertyStore.addProperties(name, propertiesBySelector)
atom.config.addScopedDefaults(args...)
removeProperties: (name) ->
@propertyStore.removeProperties(name)
atom.config.removeScopedSettingsForName(name)
clearProperties: ->
@propertyStore = new ScopedPropertyStore
atom.config.clearScopedSettings()
# Public: Get a property for the given scope and key path.
#
# ## Examples
#
# ```coffee
# comment = atom.syntax.getProperty(['.source.ruby'], 'editor.commentStart')
# console.log(comment) # '# '
# ```
#
# * `scope` An {Array} of {String} scopes.
# * `keyPath` A {String} key path.
#
# Returns a {String} property value or undefined.
getProperty: (scope, keyPath) ->
scopeChain = scope
.map (scope) ->
scope = ".#{scope}" unless scope[0] is '.'
scope
.join(' ')
@propertyStore.getPropertyValue(scopeChain, keyPath)
atom.config.getRawScopedValue(scope, keyPath)
propertiesForScope: (scope, keyPath) ->
scopeChain = scope
.map (scope) ->
scope = ".#{scope}" unless scope[0] is '.'
scope
.join(' ')
@propertyStore.getProperties(scopeChain, keyPath)
atom.config.settingsForScopeDescriptor(scope, keyPath)