Eliminate rootView.project references.

This commit is contained in:
Corey Johnson & Nathan Sobo
2013-02-19 15:15:11 -07:00
parent 7f2747ead0
commit 0b5ea8578f
22 changed files with 95 additions and 100 deletions

View File

@@ -59,7 +59,7 @@ class Editor extends View
@deserialize: (state) ->
editor = new Editor(mini: state.mini, deserializing: true)
editSessions = state.editSessions.map (state) -> EditSession.deserialize(state, rootView.project)
editSessions = state.editSessions.map (state) -> EditSession.deserialize(state, project)
editor.pushEditSession(editSession) for editSession in editSessions
editor.setActiveEditSessionIndex(state.activeEditSessionIndex)
editor.isFocused = state.isFocused

View File

@@ -37,9 +37,9 @@ class GrammarView extends SelectList
confirmed: (grammar) ->
@cancel()
if grammar is @autoDetect
rootView.project.removeGrammarOverrideForPath(@path)
project.removeGrammarOverrideForPath(@path)
else
rootView.project.addGrammarOverrideForPath(@path, grammar)
project.addGrammarOverrideForPath(@path, grammar)
@editor.reloadGrammar()
attach: ->

View File

@@ -38,12 +38,10 @@ class RootView extends View
window.rootView = this
@handleEvents()
@project = window.project
if not projectOrPathToOpen or _.isString(projectOrPathToOpen)
pathToOpen = projectOrPathToOpen
else
pathToOpen = @project?.getPath()
pathToOpen = project.getPath()
@pathToOpenIsFile = pathToOpen and fs.isFile(pathToOpen)
config.load()
@@ -79,7 +77,7 @@ class RootView extends View
@on 'root-view:active-path-changed', (e, path) =>
if path
@project.setPath(path) unless @project.getRootDirectory()
project.setPath(path) unless project.getRootDirectory()
@setTitle(fs.base(path))
else
@setTitle("untitled")
@@ -115,7 +113,7 @@ class RootView extends View
allowActiveEditorChange = options.allowActiveEditorChange ? false
unless editSession = @openInExistingEditor(path, allowActiveEditorChange, changeFocus)
editSession = @project.buildEditSessionForPath(path)
editSession = project.buildEditSessionForPath(path)
editor = new Editor({editSession})
pane = new Pane(editor)
@panes.append(pane)
@@ -130,7 +128,7 @@ class RootView extends View
if activeEditor = @getActiveEditor()
activeEditor.focus() if changeFocus
path = @project.resolve(path) if path
path = project.resolve(path) if path
if editSession = activeEditor.activateEditSessionForPath(path)
return editSession
@@ -141,7 +139,7 @@ class RootView extends View
@makeEditorActive(editor, changeFocus)
return editSession
editSession = @project.buildEditSessionForPath(path)
editSession = project.buildEditSessionForPath(path)
activeEditor.edit(editSession)
editSession
@@ -170,7 +168,7 @@ class RootView extends View
@title or "untitled"
setTitle: (title) ->
projectPath = @project.getPath()
projectPath = project.getPath()
if not projectPath
@title = "untitled"
else if title
@@ -227,7 +225,7 @@ class RootView extends View
remove: ->
editor.remove() for editor in @getEditors()
@project.destroy()
project.destroy()
super
saveAll: ->
@@ -238,10 +236,10 @@ class RootView extends View
@on 'editor:attached', (e, editor) -> callback(editor)
eachEditSession: (callback) ->
@project.eachEditSession(callback)
project.eachEditSession(callback)
eachBuffer: (callback) ->
@project.eachBuffer(callback)
project.eachBuffer(callback)
indexOfPane: (pane) ->
index = -1

View File

@@ -64,7 +64,7 @@ windowAdditions =
$(rootViewParentSelector).append(rootView)
stopApplication: ->
atom.setWindowState('pathToOpen', rootView.project.getPath())
atom.setWindowState('pathToOpen', project.getPath())
atom.setRootViewStateForPath project.getPath(),
project: project.serialize()
rootView: rootView.serialize()