mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Package loading is always synchronous, activation can be async
This commit is contained in:
@@ -87,7 +87,7 @@ class PackageManager
|
||||
# Private: Activate a single package by name
|
||||
activatePackage: (name, options) ->
|
||||
return pack if pack = @getActivePackage(name)
|
||||
if pack = @loadPackage(name, options)
|
||||
if pack = @loadPackage(name)
|
||||
@activePackages[pack.name] = pack
|
||||
pack.activate(options)
|
||||
pack
|
||||
@@ -139,7 +139,7 @@ class PackageManager
|
||||
@observingDisabledPackages = true
|
||||
|
||||
# Private:
|
||||
loadPackages: (options) ->
|
||||
loadPackages: ->
|
||||
# Ensure atom exports is already in the require cache so the load time
|
||||
# of the first package isn't skewed by being the first to require atom
|
||||
require '../exports/atom'
|
||||
@@ -147,16 +147,16 @@ class PackageManager
|
||||
packagePaths = @getAvailablePackagePaths()
|
||||
packagePaths = packagePaths.filter (packagePath) => not @isPackageDisabled(path.basename(packagePath))
|
||||
packagePaths = _.uniq packagePaths, (packagePath) -> path.basename(packagePath)
|
||||
@loadPackage(packagePath, options) for packagePath in packagePaths
|
||||
@loadPackage(packagePath) for packagePath in packagePaths
|
||||
@emit 'loaded'
|
||||
|
||||
# Private:
|
||||
loadPackage: (nameOrPath, options) ->
|
||||
loadPackage: (nameOrPath) ->
|
||||
if packagePath = @resolvePackagePath(nameOrPath)
|
||||
name = path.basename(nameOrPath)
|
||||
return pack if pack = @getLoadedPackage(name)
|
||||
|
||||
pack = Package.load(packagePath, options)
|
||||
pack = Package.load(packagePath)
|
||||
@loadedPackages[pack.name] = pack if pack?
|
||||
pack
|
||||
else
|
||||
|
||||
@@ -23,9 +23,9 @@ class Package
|
||||
|
||||
pack
|
||||
|
||||
@load: (path, options) ->
|
||||
@load: (path) ->
|
||||
pack = @build(path)
|
||||
pack?.load(options)
|
||||
pack?.load()
|
||||
pack
|
||||
|
||||
@loadMetadata: (path, ignoreErrors=false) ->
|
||||
|
||||
@@ -12,13 +12,13 @@ class TextMatePackage extends Package
|
||||
packageName = path.basename(packageName)
|
||||
/(^language-.+)|((\.|_|-)tmbundle$)/.test(packageName)
|
||||
|
||||
@getLoadQueue: ->
|
||||
return @loadQueue if @loadQueue
|
||||
@loadQueue = async.queue (pack, done) ->
|
||||
@getActivationQueue: ->
|
||||
return @activationQueue if @activationQueue?
|
||||
@activationQueue = async.queue (pack, done) ->
|
||||
pack.loadGrammars ->
|
||||
pack.loadScopedProperties(done)
|
||||
|
||||
@loadQueue
|
||||
@activationQueue
|
||||
|
||||
constructor: ->
|
||||
super
|
||||
@@ -28,21 +28,16 @@ class TextMatePackage extends Package
|
||||
|
||||
getType: -> 'textmate'
|
||||
|
||||
load: ({sync}={}) ->
|
||||
load: ->
|
||||
@measure 'loadTime', =>
|
||||
@metadata = Package.loadMetadata(@path, true)
|
||||
|
||||
if sync
|
||||
@loadGrammarsSync()
|
||||
@loadScopedPropertiesSync()
|
||||
else
|
||||
TextMatePackage.getLoadQueue().push(this)
|
||||
|
||||
activate: ->
|
||||
@measure 'activateTime', =>
|
||||
grammar.activate() for grammar in @grammars
|
||||
for { selector, properties } in @scopedProperties
|
||||
atom.syntax.addProperties(@path, selector, properties)
|
||||
activate: ({sync}={})->
|
||||
if sync
|
||||
@loadGrammarsSync()
|
||||
@loadScopedPropertiesSync()
|
||||
else
|
||||
TextMatePackage.getActivationQueue().push(this)
|
||||
|
||||
activateConfig: -> # noop
|
||||
|
||||
|
||||
Reference in New Issue
Block a user