mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Wait until TextMate packages are activated to add grammars/properties
My plan is to cache the loading of packages so we don't have to load them from the disk repeatedly in specs. The first step of this is ensuring that load has no side-effects.
This commit is contained in:
@@ -13,6 +13,7 @@ _.extend atom,
|
||||
loadedThemes: []
|
||||
pendingBrowserProcessCallbacks: {}
|
||||
loadedPackages: []
|
||||
activePackages: []
|
||||
activatedAtomPackages: []
|
||||
atomPackageStates: {}
|
||||
presentingModal: false
|
||||
@@ -50,7 +51,12 @@ _.extend atom,
|
||||
pack.load()
|
||||
|
||||
activatePackages: ->
|
||||
pack.activate() for pack in @loadedPackages
|
||||
for pack in @loadedPackages
|
||||
@activePackages.push(pack)
|
||||
pack.activate()
|
||||
|
||||
isPackageActive: (pack) ->
|
||||
_.include(@activePackages, pack)
|
||||
|
||||
getLoadedPackages: ->
|
||||
_.clone(@loadedPackages)
|
||||
|
||||
@@ -31,6 +31,11 @@ class TextMatePackage extends Package
|
||||
TextMatePackage.getLoadQueue().push(this)
|
||||
@loadScopedProperties()
|
||||
|
||||
activate: ->
|
||||
syntax.addGrammar(grammar) for grammar in @grammars
|
||||
for { selector, properties } in @scopedProperties
|
||||
syntax.addProperties(selector, properties)
|
||||
|
||||
legalGrammarExtensions: ['plist', 'tmLanguage', 'tmlanguage', 'cson', 'json']
|
||||
|
||||
loadGrammars: (done) ->
|
||||
@@ -52,30 +57,22 @@ class TextMatePackage extends Package
|
||||
|
||||
addGrammar: (grammar) ->
|
||||
@grammars.push(grammar)
|
||||
syntax.addGrammar(grammar)
|
||||
|
||||
activate: -> # no-op
|
||||
syntax.addGrammar(grammar) if atom.isPackageActive(this)
|
||||
|
||||
getGrammars: -> @grammars
|
||||
|
||||
loadScopedProperties: ->
|
||||
for { selector, properties } in @getScopedProperties()
|
||||
syntax.addProperties(selector, properties)
|
||||
|
||||
getScopedProperties: ->
|
||||
scopedProperties = []
|
||||
@scopedProperties = []
|
||||
|
||||
for grammar in @getGrammars()
|
||||
if properties = @propertiesFromTextMateSettings(grammar)
|
||||
selector = syntax.cssSelectorFromScopeSelector(grammar.scopeName)
|
||||
scopedProperties.push({selector, properties})
|
||||
@scopedProperties.push({selector, properties})
|
||||
|
||||
for {scope, settings} in @getTextMatePreferenceObjects()
|
||||
if properties = @propertiesFromTextMateSettings(settings)
|
||||
selector = syntax.cssSelectorFromScopeSelector(scope) if scope?
|
||||
scopedProperties.push({selector, properties})
|
||||
|
||||
scopedProperties
|
||||
@scopedProperties.push({selector, properties})
|
||||
|
||||
getTextMatePreferenceObjects: ->
|
||||
preferenceObjects = []
|
||||
|
||||
Reference in New Issue
Block a user