mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Construct Project during Atom environment construction
Signed-off-by: Max Brunsfeld <maxbrunsfeld@github.com>
This commit is contained in:
@@ -277,7 +277,7 @@ describe "GitRepository", ->
|
||||
atom.workspace.open('file.txt')
|
||||
|
||||
runs ->
|
||||
project2 = new Project()
|
||||
project2 = new Project({notificationManager: atom.notifications, packageManager: atom.packages, confirm: atom.confirm})
|
||||
project2.deserialize(atom.project.serialize(), atom.deserializers)
|
||||
buffer = project2.getBuffers()[0]
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ describe "Project", ->
|
||||
runs ->
|
||||
expect(atom.project.getBuffers().length).toBe 1
|
||||
|
||||
deserializedProject = new Project()
|
||||
deserializedProject = new Project({notificationManager: atom.notifications, packageManager: atom.packages, confirm: atom.confirm})
|
||||
deserializedProject.deserialize(atom.project.serialize(), atom.deserializers)
|
||||
expect(deserializedProject.getBuffers().length).toBe 0
|
||||
|
||||
@@ -77,7 +77,7 @@ describe "Project", ->
|
||||
|
||||
runs ->
|
||||
expect(atom.project.getBuffers().length).toBe 1
|
||||
deserializedProject = new Project
|
||||
deserializedProject = new Project({notificationManager: atom.notifications, packageManager: atom.packages, confirm: atom.confirm})
|
||||
deserializedProject.deserialize(atom.project.serialize(), atom.deserializers)
|
||||
|
||||
expect(deserializedProject.getBuffers().length).toBe 1
|
||||
@@ -94,7 +94,7 @@ describe "Project", ->
|
||||
runs ->
|
||||
expect(atom.project.getBuffers().length).toBe 1
|
||||
fs.mkdirSync(pathToOpen)
|
||||
deserializedProject = new Project
|
||||
deserializedProject = new Project({notificationManager: atom.notifications, packageManager: atom.packages, confirm: atom.confirm})
|
||||
deserializedProject.deserialize(atom.project.serialize(), atom.deserializers)
|
||||
expect(deserializedProject.getBuffers().length).toBe 0
|
||||
|
||||
@@ -108,7 +108,7 @@ describe "Project", ->
|
||||
runs ->
|
||||
expect(atom.project.getBuffers().length).toBe 1
|
||||
fs.chmodSync(pathToOpen, '000')
|
||||
deserializedProject = new Project()
|
||||
deserializedProject = new Project({notificationManager: atom.notifications, packageManager: atom.packages, confirm: atom.confirm})
|
||||
deserializedProject.deserialize(atom.project.serialize(), atom.deserializers)
|
||||
expect(deserializedProject.getBuffers().length).toBe 0
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ beforeEach ->
|
||||
documentTitle = null
|
||||
projectPath = specProjectPath ? path.join(@specDirectory, 'fixtures')
|
||||
atom.packages.serviceHub = new ServiceHub
|
||||
atom.project = new Project
|
||||
atom.project = new Project({notificationManager: atom.notifications, packageManager: atom.packages, confirm: atom.confirm})
|
||||
atom.project.setPaths([projectPath])
|
||||
atom.workspace = new Workspace()
|
||||
atom.themes.workspace = atom.workspace
|
||||
|
||||
@@ -22,7 +22,7 @@ describe "Workspace", ->
|
||||
projectState = atom.project.serialize()
|
||||
atom.workspace.destroy()
|
||||
atom.project.destroy()
|
||||
atom.project = new Project()
|
||||
atom.project = new Project({notificationManager: atom.notifications, packageManager: atom.packages, confirm: atom.confirm})
|
||||
atom.project.deserialize(projectState, atom.deserializers)
|
||||
atom.workspace = Workspace.deserialize(workspaceState)
|
||||
|
||||
|
||||
@@ -160,6 +160,9 @@ class Atom extends Model
|
||||
GrammarRegistry = require './grammar-registry'
|
||||
@grammars = new GrammarRegistry({@config})
|
||||
|
||||
Project = require './project'
|
||||
@project = new Project({notificationManager: @notifications, packageManager: @packages, @confirm})
|
||||
|
||||
setConfigSchema: ->
|
||||
@config.setSchema null, {type: 'object', properties: _.clone(require('./config-schema'))}
|
||||
|
||||
@@ -651,13 +654,6 @@ class Atom extends Model
|
||||
|
||||
false
|
||||
|
||||
deserializeProject: ->
|
||||
Project = require './project'
|
||||
startTime = Date.now()
|
||||
@project = new Project()
|
||||
@project.deserialize(@state.project, @deserializers) if @state.project?
|
||||
@deserializeTimings.project = Date.now() - startTime
|
||||
|
||||
deserializeWorkspace: ->
|
||||
Workspace = require './workspace'
|
||||
|
||||
@@ -679,7 +675,6 @@ class Atom extends Model
|
||||
@grammars.grammarOverridesByPath = grammarOverridesByPath
|
||||
|
||||
@deserializePackageStates()
|
||||
@deserializeProject()
|
||||
@deserializeWorkspace()
|
||||
|
||||
loadThemes: ->
|
||||
@@ -741,6 +736,10 @@ class Atom extends Model
|
||||
|
||||
@deserializeTimings.atom = Date.now() - startTime
|
||||
|
||||
startTime = Date.now()
|
||||
@project.deserialize(@state.project, @deserializers) if @state.project?
|
||||
@deserializeTimings.project = Date.now() - startTime
|
||||
|
||||
getStateKey: (paths) ->
|
||||
if paths?.length > 0
|
||||
sha1 = crypto.createHash('sha1').update(paths.slice().sort().join("\n")).digest('hex')
|
||||
|
||||
@@ -21,7 +21,7 @@ class Project extends Model
|
||||
Section: Construction and Destruction
|
||||
###
|
||||
|
||||
constructor: ->
|
||||
constructor: ({@confirm, @notificationManager, packageManager}) ->
|
||||
@emitter = new Emitter
|
||||
@buffers = []
|
||||
@paths = []
|
||||
@@ -30,7 +30,7 @@ class Project extends Model
|
||||
|
||||
@directoryProviders = []
|
||||
@defaultDirectoryProvider = new DefaultDirectoryProvider()
|
||||
atom.packages.serviceHub.consume(
|
||||
packageManager.serviceHub.consume(
|
||||
'atom.directory-provider',
|
||||
'^0.1.0',
|
||||
(provider) => @directoryProviders.unshift(provider))
|
||||
@@ -42,7 +42,7 @@ class Project extends Model
|
||||
@repositoryPromisesByPath = new Map()
|
||||
|
||||
@repositoryProviders = [new GitRepositoryProvider(this)]
|
||||
atom.packages.serviceHub.consume(
|
||||
packageManager.serviceHub.consume(
|
||||
'atom.repository-provider',
|
||||
'^0.1.0',
|
||||
(provider) =>
|
||||
@@ -417,9 +417,9 @@ class Project extends Model
|
||||
|
||||
subscribeToBuffer: (buffer) ->
|
||||
buffer.onDidDestroy => @removeBuffer(buffer)
|
||||
buffer.onWillThrowWatchError ({error, handle}) ->
|
||||
buffer.onWillThrowWatchError ({error, handle}) =>
|
||||
handle()
|
||||
atom.notifications.addWarning """
|
||||
@notificationManager.addWarning """
|
||||
Unable to read file after file `#{error.eventType}` event.
|
||||
Make sure you have permission to access `#{buffer.getPath()}`.
|
||||
""",
|
||||
|
||||
Reference in New Issue
Block a user