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

@ -22,7 +22,7 @@ describe "editor.", ->
editor.on 'editor:display-updated', done
runs ->
projectPath = rootView.project.getPath()
projectPath = project.getPath()
$(window).off 'beforeunload'
window.shutdown()
atom.setRootViewStateForPath(projectPath, null)
@ -38,7 +38,7 @@ describe "editor.", ->
describe "opening-buffers.", ->
benchmark "300-line-file.", ->
buffer = rootView.project.bufferForPath('medium.coffee')
buffer = project.bufferForPath('medium.coffee')
describe "empty-file.", ->
benchmark "insert-delete", ->

View File

@ -10,11 +10,11 @@ _ = require 'underscore'
fs = require 'fs'
describe "Editor", ->
[project, buffer, editor, cachedLineHeight] = []
[buffer, editor, cachedLineHeight] = []
getLineHeight = ->
return cachedLineHeight if cachedLineHeight?
editorForMeasurement = new Editor(editSession: rootView.project.buildEditSessionForPath('sample.js'))
editorForMeasurement = new Editor(editSession: project.buildEditSessionForPath('sample.js'))
editorForMeasurement.attachToDom()
cachedLineHeight = editorForMeasurement.lineHeight
editorForMeasurement.remove()
@ -22,7 +22,6 @@ describe "Editor", ->
beforeEach ->
new RootView(require.resolve('fixtures/sample.js'))
project = rootView.project
editor = rootView.getActiveEditor()
buffer = editor.getBuffer()
@ -49,7 +48,7 @@ describe "Editor", ->
rootView.height(8 * editor.lineHeight)
rootView.width(50 * editor.charWidth)
editor.edit(rootView.project.buildEditSessionForPath('two-hundred.txt'))
editor.edit(project.buildEditSessionForPath('two-hundred.txt'))
editor.setCursorScreenPosition([5, 1])
editor.scrollTop(1.5 * editor.lineHeight)
editor.scrollView.scrollLeft(44)
@ -78,7 +77,7 @@ describe "Editor", ->
it "does not blow up if no file exists for a previous edit session, but prints a warning", ->
spyOn(console, 'warn')
fs.write('/tmp/delete-me')
editor.edit(rootView.project.buildEditSessionForPath('/tmp/delete-me'))
editor.edit(project.buildEditSessionForPath('/tmp/delete-me'))
fs.remove('/tmp/delete-me')
newEditor = editor.copy()
expect(console.warn).toHaveBeenCalled()
@ -140,7 +139,7 @@ describe "Editor", ->
describe ".remove()", ->
it "removes subscriptions from all edit session buffers", ->
previousEditSession = editor.activeEditSession
otherEditSession = rootView.project.buildEditSessionForPath(rootView.project.resolve('sample.txt'))
otherEditSession = project.buildEditSessionForPath(project.resolve('sample.txt'))
expect(previousEditSession.buffer.subscriptionCount()).toBeGreaterThan 1
editor.edit(otherEditSession)
@ -152,17 +151,17 @@ describe "Editor", ->
describe "when 'close' is triggered", ->
it "adds a closed session path to the array", ->
editor.edit(rootView.project.buildEditSessionForPath())
editor.edit(project.buildEditSessionForPath())
editSession = editor.activeEditSession
expect(editor.closedEditSessions.length).toBe 0
editor.trigger "core:close"
expect(editor.closedEditSessions.length).toBe 0
editor.edit(rootView.project.buildEditSessionForPath(rootView.project.resolve('sample.txt')))
editor.edit(project.buildEditSessionForPath(project.resolve('sample.txt')))
editor.trigger "core:close"
expect(editor.closedEditSessions.length).toBe 1
it "closes the active edit session and loads next edit session", ->
editor.edit(rootView.project.buildEditSessionForPath())
editor.edit(project.buildEditSessionForPath())
editSession = editor.activeEditSession
spyOn(editSession.buffer, 'isModified').andReturn false
spyOn(editSession, 'destroy').andCallThrough()
@ -173,7 +172,7 @@ describe "Editor", ->
expect(editor.getBuffer()).toBe buffer
it "triggers the 'editor:edit-session-removed' event with the edit session and its former index", ->
editor.edit(rootView.project.buildEditSessionForPath())
editor.edit(project.buildEditSessionForPath())
editSession = editor.activeEditSession
index = editor.getActiveEditSessionIndex()
spyOn(editSession.buffer, 'isModified').andReturn false
@ -221,7 +220,7 @@ describe "Editor", ->
otherEditSession = null
beforeEach ->
otherEditSession = rootView.project.buildEditSessionForPath()
otherEditSession = project.buildEditSessionForPath()
describe "when the edit session wasn't previously assigned to this editor", ->
it "adds edit session to editor and triggers the 'editor:edit-session-added' event", ->
@ -258,11 +257,11 @@ describe "Editor", ->
expect(editor.lineElementForScreenRow(0).text()).toBe 'def'
it "removes the opened session from the closed sessions array", ->
editor.edit(rootView.project.buildEditSessionForPath('sample.txt'))
editor.edit(project.buildEditSessionForPath('sample.txt'))
expect(editor.closedEditSessions.length).toBe 0
editor.trigger "core:close"
expect(editor.closedEditSessions.length).toBe 1
editor.edit(rootView.project.buildEditSessionForPath('sample.txt'))
editor.edit(project.buildEditSessionForPath('sample.txt'))
expect(editor.closedEditSessions.length).toBe 0
describe "switching edit sessions", ->
@ -271,10 +270,10 @@ describe "Editor", ->
beforeEach ->
session0 = editor.activeEditSession
editor.edit(rootView.project.buildEditSessionForPath('sample.txt'))
editor.edit(project.buildEditSessionForPath('sample.txt'))
session1 = editor.activeEditSession
editor.edit(rootView.project.buildEditSessionForPath('two-hundred.txt'))
editor.edit(project.buildEditSessionForPath('two-hundred.txt'))
session2 = editor.activeEditSession
describe ".setActiveEditSessionIndex(index)", ->
@ -363,7 +362,7 @@ describe "Editor", ->
fs.write(tempFilePath, "")
new RootView(tempFilePath)
editor = rootView.getActiveEditor()
project = rootView.project
project = project
expect(editor.getPath()).toBe tempFilePath
@ -382,7 +381,7 @@ describe "Editor", ->
describe "when the current buffer has no path", ->
selectedFilePath = null
beforeEach ->
editor.edit(rootView.project.buildEditSessionForPath())
editor.edit(project.buildEditSessionForPath())
expect(editor.getPath()).toBeUndefined()
editor.getBuffer().setText 'Save me to a new path'
@ -509,7 +508,7 @@ describe "Editor", ->
it "emits event when editor receives a new buffer", ->
eventHandler = jasmine.createSpy('eventHandler')
editor.on 'editor:path-changed', eventHandler
editor.edit(rootView.project.buildEditSessionForPath(path))
editor.edit(project.buildEditSessionForPath(path))
expect(eventHandler).toHaveBeenCalled()
it "stops listening to events on previously set buffers", ->
@ -517,7 +516,7 @@ describe "Editor", ->
oldBuffer = editor.getBuffer()
editor.on 'editor:path-changed', eventHandler
editor.edit(rootView.project.buildEditSessionForPath(path))
editor.edit(project.buildEditSessionForPath(path))
expect(eventHandler).toHaveBeenCalled()
eventHandler.reset()
@ -1378,7 +1377,7 @@ describe "Editor", ->
expect(editor.bufferPositionForScreenPosition(editor.getCursorScreenPosition())).toEqual [3, 60]
it "does not wrap the lines of any newly assigned buffers", ->
otherEditSession = rootView.project.buildEditSessionForPath()
otherEditSession = project.buildEditSessionForPath()
otherEditSession.buffer.setText([1..100].join(''))
editor.edit(otherEditSession)
expect(editor.renderedLines.find('.line').length).toBe(1)
@ -1414,7 +1413,7 @@ describe "Editor", ->
expect(editor.getCursorScreenPosition()).toEqual [11, 0]
it "calls .setSoftWrapColumn() when the editor is attached because now its dimensions are available to calculate it", ->
otherEditor = new Editor(editSession: rootView.project.buildEditSessionForPath('sample.js'))
otherEditor = new Editor(editSession: project.buildEditSessionForPath('sample.js'))
spyOn(otherEditor, 'setSoftWrapColumn')
otherEditor.setSoftWrap(true)
@ -1710,7 +1709,7 @@ describe "Editor", ->
describe "when autoscrolling at the end of the document", ->
it "renders lines properly", ->
editor.edit(rootView.project.buildEditSessionForPath('two-hundred.txt'))
editor.edit(project.buildEditSessionForPath('two-hundred.txt'))
editor.attachToDom(heightInLines: 5.5)
expect(editor.renderedLines.find('.line').length).toBe 8
@ -2055,7 +2054,7 @@ describe "Editor", ->
describe "folding", ->
beforeEach ->
editSession = rootView.project.buildEditSessionForPath('two-hundred.txt')
editSession = project.buildEditSessionForPath('two-hundred.txt')
buffer = editSession.buffer
editor.edit(editSession)
editor.attachToDom()
@ -2322,7 +2321,7 @@ describe "Editor", ->
rootView.attachToDom()
afterEach ->
rootView.project.removeGrammarOverrideForPath(path)
project.removeGrammarOverrideForPath(path)
fs.remove(path) if fs.exists(path)
it "updates all the rendered lines when the grammar changes", ->
@ -2332,7 +2331,7 @@ describe "Editor", ->
jsGrammar = syntax.grammarForFilePath('/tmp/js.js')
expect(jsGrammar.name).toBe 'JavaScript'
rootView.project.addGrammarOverrideForPath(path, jsGrammar)
project.addGrammarOverrideForPath(path, jsGrammar)
expect(editor.reloadGrammar()).toBeTruthy()
expect(editor.getGrammar()).toBe jsGrammar
@ -2365,7 +2364,7 @@ describe "Editor", ->
expect(eventHandler).not.toHaveBeenCalled()
jsGrammar = syntax.grammarForFilePath('/tmp/js.js')
rootView.project.addGrammarOverrideForPath(path, jsGrammar)
project.addGrammarOverrideForPath(path, jsGrammar)
editor.reloadGrammar()
expect(eventHandler).toHaveBeenCalled()

View File

@ -8,7 +8,7 @@ describe "GrammarView", ->
beforeEach ->
path = require.resolve('fixtures/sample.js')
rootView = new RootView()
rootView.project.removeGrammarOverrideForPath(path)
project.removeGrammarOverrideForPath(path)
rootView.open(path)
editor = rootView.getActiveEditor()
rootView.attachToDom()

View File

@ -36,9 +36,9 @@ describe "RootView", ->
rootView = new RootView(pathToOpen)
rootView.focus()
expect(rootView.project.getPath()).toBe pathToOpen
expect(project.getPath()).toBe pathToOpen
expect(rootView.getEditors().length).toBe 0
expect(rootView.getTitle()).toBe rootView.project.getPath()
expect(rootView.getTitle()).toBe project.getPath()
describe "when called with no pathToOpen", ->
it "opens an empty buffer", ->
@ -88,10 +88,10 @@ describe "RootView", ->
editor3 = editor2.splitRight()
editor4 = editor2.splitDown()
editor2.edit(rootView.project.buildEditSessionForPath('dir/b'))
editor3.edit(rootView.project.buildEditSessionForPath('sample.js'))
editor2.edit(project.buildEditSessionForPath('dir/b'))
editor3.edit(project.buildEditSessionForPath('sample.js'))
editor3.setCursorScreenPosition([2, 4])
editor4.edit(rootView.project.buildEditSessionForPath('sample.txt'))
editor4.edit(project.buildEditSessionForPath('sample.txt'))
editor4.setCursorScreenPosition([0, 2])
rootView.attachToDom()
editor2.focus()
@ -127,7 +127,7 @@ describe "RootView", ->
expect(editor3.isFocused).toBeFalsy()
expect(editor4.isFocused).toBeFalsy()
expect(rootView.getTitle()).toBe "#{fs.base(editor2.getPath())} #{rootView.project.getPath()}"
expect(rootView.getTitle()).toBe "#{fs.base(editor2.getPath())} #{project.getPath()}"
describe "where there are no open editors", ->
beforeEach ->
@ -450,27 +450,27 @@ describe "RootView", ->
rootView.on 'root-view:active-path-changed', pathChangeHandler
editor1 = rootView.getActiveEditor()
expect(rootView.getTitle()).toBe "#{fs.base(editor1.getPath())} #{rootView.project.getPath()}"
expect(rootView.getTitle()).toBe "#{fs.base(editor1.getPath())} #{project.getPath()}"
editor2 = rootView.getActiveEditor().splitLeft()
path = rootView.project.resolve('b')
editor2.edit(rootView.project.buildEditSessionForPath(path))
path = project.resolve('b')
editor2.edit(project.buildEditSessionForPath(path))
expect(pathChangeHandler).toHaveBeenCalled()
expect(rootView.getTitle()).toBe "#{fs.base(editor2.getPath())} #{rootView.project.getPath()}"
expect(rootView.getTitle()).toBe "#{fs.base(editor2.getPath())} #{project.getPath()}"
pathChangeHandler.reset()
editor1.getBuffer().saveAs("/tmp/should-not-be-title.txt")
expect(pathChangeHandler).not.toHaveBeenCalled()
expect(rootView.getTitle()).toBe "#{fs.base(editor2.getPath())} #{rootView.project.getPath()}"
expect(rootView.getTitle()).toBe "#{fs.base(editor2.getPath())} #{project.getPath()}"
it "sets the project path to the directory of the editor if it was previously unassigned", ->
project.setPath(undefined)
rootView = new RootView
rootView.open()
expect(rootView.project.getPath()?).toBeFalsy()
expect(project.getPath()?).toBeFalsy()
rootView.getActiveEditor().getBuffer().saveAs('/tmp/ignore-me')
expect(rootView.project.getPath()).toBe '/tmp'
expect(project.getPath()).toBe '/tmp'
describe "when editors are focused", ->
it "triggers 'root-view:active-path-changed' events if the path of the active editor actually changes", ->
@ -498,7 +498,7 @@ describe "RootView", ->
describe "when the last editor is removed", ->
it "updates the title to the project path", ->
rootView.getEditors()[0].remove()
expect(rootView.getTitle()).toBe rootView.project.getPath()
expect(rootView.getTitle()).toBe project.getPath()
describe "font size adjustment", ->
editor = null
@ -635,7 +635,7 @@ describe "RootView", ->
expect(buffer1.isModified()).toBe(true)
editor2 = editor1.splitRight()
editor2.edit(rootView.project.buildEditSessionForPath('atom-temp2.txt'))
editor2.edit(project.buildEditSessionForPath('atom-temp2.txt'))
buffer2 = editor2.activeEditSession.buffer
expect(buffer2.getText()).toBe("file2")
expect(buffer2.isModified()).toBe(false)

View File

@ -12,7 +12,7 @@ describe "Window", ->
afterEach ->
window.stopApplication()
atom.setRootViewStateForPath(rootView.project.getPath(), null)
atom.setRootViewStateForPath(project.getPath(), null)
$(window).off 'beforeunload'
describe "when the window is loaded", ->
@ -89,7 +89,7 @@ describe "Window", ->
describe "stopApplication()", ->
it "saves the serialized state of the project and root view to the atom object so it can be rehydrated after reload", ->
expect(atom.getRootViewStateForPath(rootView.project.getPath())).toBeUndefined()
expect(atom.getRootViewStateForPath(project.getPath())).toBeUndefined()
# JSON.stringify removes keys with undefined values
rootViewState = JSON.parse(JSON.stringify(rootView.serialize()))
projectState = JSON.parse(JSON.stringify(project.serialize()))

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()

View File

@ -30,7 +30,7 @@ class CommandPanelView extends View
maxSerializedHistorySize: 100
initialize: (state) ->
@commandInterpreter = new CommandInterpreter(rootView.project)
@commandInterpreter = new CommandInterpreter(project)
@command 'tool-panel:unfocus', => rootView.focus()
@command 'core:close', => @detach(); false

View File

@ -3,13 +3,12 @@ CommandPanelView = require 'command-panel/lib/command-panel-view'
_ = require 'underscore'
describe "CommandPanel", ->
[editor, buffer, commandPanel, project, CommandPanel] = []
[editor, buffer, commandPanel, CommandPanel] = []
beforeEach ->
new RootView
rootView.open(require.resolve 'fixtures/sample.js')
rootView.enableKeymap()
project = rootView.project
editor = rootView.getActiveEditor()
buffer = editor.activeEditSession.buffer
commandPanelMain = window.loadPackage('command-panel', activateImmediately: true).packageMain

View File

@ -65,13 +65,13 @@ class FuzzyFinderView extends SelectList
editor = rootView.getActiveEditor()
if editor
fn(editor, rootView.project.buildEditSessionForPath(path))
fn(editor, project.buildEditSessionForPath(path))
else
@openPath(path)
confirmed : (path) ->
return unless path.length
if fs.isFile(rootView.project.resolve(path))
if fs.isFile(project.resolve(path))
@cancel()
@openPath(path)
else
@ -82,7 +82,7 @@ class FuzzyFinderView extends SelectList
if @hasParent()
@cancel()
else
return unless rootView.project.getPath()?
return unless project.getPath()?
@allowActiveEditorChange = false
@populateProjectPaths()
@attach()
@ -99,7 +99,7 @@ class FuzzyFinderView extends SelectList
if @hasParent()
@cancel()
else
return unless rootView.project.getPath()?
return unless project.getPath()?
@allowActiveEditorChange = false
editor = rootView.getActiveEditor()
currentWord = editor.getWordUnderCursor(wordRegex: @filenameRegex)
@ -149,7 +149,7 @@ class FuzzyFinderView extends SelectList
@loadPathsTask.start()
populateOpenBufferPaths: ->
editSessions = rootView.project.getEditSessions().filter (editSession)->
editSessions = project.getEditSessions().filter (editSession)->
editSession.getPath()?
editSessions = _.sortBy editSessions, (editSession) =>
@ -159,13 +159,13 @@ class FuzzyFinderView extends SelectList
-(editSession.lastOpened or 1)
@paths = _.map editSessions, (editSession) ->
rootView.project.relativize editSession.getPath()
project.relativize editSession.getPath()
@setArray(@paths)
getOpenedPaths: ->
paths = {}
for editSession in rootView.project.getEditSessions()
for editSession in project.getEditSessions()
path = editSession.getPath()
paths[path] = editSession.lastOpened if path?
paths

View File

@ -13,12 +13,12 @@ module.exports =
rootView.command 'fuzzy-finder:find-under-cursor', =>
@createView().findUnderCursor()
if rootView.project.getPath()?
if project.getPath()?
LoadPathsTask = require 'fuzzy-finder/lib/load-paths-task'
@loadPathsTask = new LoadPathsTask((paths) => @projectPaths = paths)
@loadPathsTask.start()
for editSession in rootView.project.getEditSessions()
for editSession in project.getEditSessions()
editSession.lastOpened = state[editSession.getPath()]
deactivate: ->

View File

@ -9,7 +9,7 @@ class LoadPathsTask extends Task
ignoredNames = config.get('fuzzyFinder.ignoredNames') ? []
ignoredNames = ignoredNames.concat(config.get('core.ignoredNames') ? [])
excludeGitIgnoredPaths = config.get('core.hideGitIgnoredFiles')
rootPath = rootView.project.getPath()
rootPath = project.getPath()
@callWorkerMethod('loadPaths', rootPath, ignoredNames, excludeGitIgnoredPaths)
pathsLoaded: (paths) ->

View File

@ -64,7 +64,7 @@ describe 'FuzzyFinder', ->
describe "when root view's project has no path", ->
beforeEach ->
rootView.project.setPath(null)
project.setPath(null)
it "does not open the FuzzyFinder", ->
expect(rootView.find('.fuzzy-finder')).not.toExist()
@ -165,7 +165,7 @@ describe 'FuzzyFinder', ->
describe "when the active editor only contains edit sessions for anonymous buffers", ->
it "does not open", ->
editor = rootView.getActiveEditor()
editor.edit(rootView.project.buildEditSessionForPath())
editor.edit(project.buildEditSessionForPath())
editor.loadPreviousEditSession()
editor.destroyActiveEditSession()
expect(editor.getOpenBufferPaths().length).toBe 0
@ -276,15 +276,15 @@ describe 'FuzzyFinder', ->
expect(finderView.loadPathsTask.start).not.toHaveBeenCalled()
it "doesn't cache buffer paths", ->
spyOn(rootView.project, "getEditSessions").andCallThrough()
spyOn(project, "getEditSessions").andCallThrough()
rootView.trigger 'fuzzy-finder:toggle-buffer-finder'
waitsFor ->
finderView.list.children('li').length > 0
runs ->
expect(rootView.project.getEditSessions).toHaveBeenCalled()
rootView.project.getEditSessions.reset()
expect(project.getEditSessions).toHaveBeenCalled()
project.getEditSessions.reset()
rootView.trigger 'fuzzy-finder:toggle-buffer-finder'
rootView.trigger 'fuzzy-finder:toggle-buffer-finder'
@ -292,7 +292,7 @@ describe 'FuzzyFinder', ->
finderView.list.children('li').length > 0
runs ->
expect(rootView.project.getEditSessions).toHaveBeenCalled()
expect(project.getEditSessions).toHaveBeenCalled()
it "busts the cache when the window gains focus", ->
spyOn(LoadPathsTask.prototype, "start").andCallThrough()

View File

@ -39,7 +39,7 @@ describe "MarkdownPreview", ->
gfmGrammar = _.find syntax.grammars, (grammar) -> grammar.scopeName is 'source.gfm'
rootView.open('file.js')
editor = rootView.getActiveEditor()
rootView.project.addGrammarOverrideForPath(editor.getPath(), gfmGrammar)
project.addGrammarOverrideForPath(editor.getPath(), gfmGrammar)
editor.reloadGrammar()
expect(rootView.find('.markdown-preview')).not.toExist()
editor.trigger('markdown-preview:toggle')

View File

@ -99,7 +99,7 @@ class StatusBarView extends View
updatePathText: ->
if path = @editor.getPath()
@currentPath.text(rootView.project.relativize(path))
@currentPath.text(project.relativize(path))
else
@currentPath.text('untitled')

View File

@ -114,13 +114,13 @@ describe "StatusBar", ->
it "displays the current branch for files in repositories", ->
path = require.resolve('fixtures/git/master.git/HEAD')
rootView.project.setPath(require.resolve('fixtures/git/master.git'))
project.setPath(require.resolve('fixtures/git/master.git'))
rootView.open(path)
expect(statusBar.branchArea).toBeVisible()
expect(statusBar.branchLabel.text()).toBe 'master'
it "doesn't display the current branch for a file not in a repository", ->
rootView.project.setPath('/tmp')
project.setPath('/tmp')
rootView.open('/tmp/temp.txt')
expect(statusBar.branchArea).toBeHidden()
expect(statusBar.branchLabel.text()).toBe ''
@ -184,7 +184,7 @@ describe "StatusBar", ->
describe "when the editor's grammar changes", ->
it "displays the new grammar of the editor", ->
textGrammar = _.find syntax.grammars, (grammar) -> grammar.name is 'Plain Text'
rootView.project.addGrammarOverrideForPath(editor.getPath(), textGrammar)
project.addGrammarOverrideForPath(editor.getPath(), textGrammar)
editor.reloadGrammar()
expect(statusBar.find('.grammar-name').text()).toBe textGrammar.name

View File

@ -67,7 +67,7 @@ class SymbolsView extends SelectList
populateProjectSymbols: ->
@list.empty()
@setLoading("Loading symbols...")
TagReader.getAllTags(rootView.project).done (tags) =>
TagReader.getAllTags(project).done (tags) =>
if tags.length > 0
@miniEditor.show()
@maxItems = 10
@ -102,7 +102,7 @@ class SymbolsView extends SelectList
getTagLine: (tag) ->
pattern = $.trim(tag.pattern?.replace(/(^^\/\^)|(\$\/$)/g, '')) # Remove leading /^ and trailing $/
return unless pattern
file = rootView.project.resolve(tag.file)
file = project.resolve(tag.file)
return unless fs.isFile(file)
for line, index in fs.read(file).split('\n')
return new Point(index, 0) if pattern is $.trim(line)

View File

@ -11,7 +11,7 @@ find: (editor) ->
word = editor.getTextInRange(editor.getCursor().getCurrentWordBufferRange())
return [] unless word.length > 0
tagsFile = @getTagsFile(rootView.project)
tagsFile = @getTagsFile(project)
return [] unless tagsFile
$tags.find(tagsFile, word) or []

View File

@ -152,15 +152,15 @@ describe "SymbolsView", ->
expect(symbolsView.list.children('li').length).toBe 2
expect(symbolsView).toBeVisible()
symbolsView.confirmed(symbolsView.array[0])
expect(rootView.getActiveEditor().getPath()).toBe rootView.project.resolve("tagged-duplicate.js")
expect(rootView.getActiveEditor().getPath()).toBe project.resolve("tagged-duplicate.js")
expect(rootView.getActiveEditor().getCursorBufferPosition()).toEqual [0,4]
describe "when the tag is in a file that doesn't exist", ->
beforeEach ->
fs.move(rootView.project.resolve("tagged-duplicate.js"), rootView.project.resolve("tagged-duplicate-renamed.js"))
fs.move(project.resolve("tagged-duplicate.js"), project.resolve("tagged-duplicate-renamed.js"))
afterEach ->
fs.move(rootView.project.resolve("tagged-duplicate-renamed.js"), rootView.project.resolve("tagged-duplicate.js"))
fs.move(project.resolve("tagged-duplicate-renamed.js"), project.resolve("tagged-duplicate.js"))
it "doesn't display the tag", ->
rootView.open("tagged.js")

View File

@ -41,7 +41,7 @@ class TreeView extends ScrollView
@selectActiveFile()
rootView.on 'root-view:active-path-changed', => @selectActiveFile()
rootView.project.on 'path-changed', => @updateRoot()
project.on 'path-changed', => @updateRoot()
@observeConfig 'core.hideGitIgnoredFiles', => @updateRoot()
if @root
@ -78,7 +78,7 @@ class TreeView extends ScrollView
@attach()
attach: ->
return unless rootView.project.getPath()
return unless project.getPath()
rootView.horizontal.prepend(this)
@focus()
@ -122,8 +122,8 @@ class TreeView extends ScrollView
updateRoot: ->
@root?.remove()
if rootDirectory = rootView.project.getRootDirectory()
@root = new DirectoryView(directory: rootDirectory, isExpanded: true, project: rootView.project)
if rootDirectory = project.getRootDirectory()
@root = new DirectoryView(directory: rootDirectory, isExpanded: true, project: project)
@treeViewList.append(@root)
else
@root = null
@ -137,7 +137,6 @@ class TreeView extends ScrollView
return unless activeFilePath = rootView.getActiveEditor()?.getPath()
project = rootView.project
activePathComponents = project.relativize(activeFilePath).split('/')
currentPath = project.getPath().replace(/\/$/, '')
for pathComponent in activePathComponents
@ -217,11 +216,11 @@ class TreeView extends ScrollView
dialog = new Dialog
prompt: prompt
path: rootView.project.relativize(oldPath)
path: project.relativize(oldPath)
select: true
iconClass: 'move'
onConfirm: (newPath) =>
newPath = rootView.project.resolve(newPath)
newPath = project.resolve(newPath)
directoryPath = fs.directory(newPath)
try
fs.makeTree(directoryPath) unless fs.exists(directoryPath)
@ -249,7 +248,7 @@ class TreeView extends ScrollView
selectedEntry = @selectedEntry() or @root
selectedPath = selectedEntry.getPath()
directoryPath = if fs.isFile(selectedPath) then fs.directory(selectedPath) else selectedPath
relativeDirectoryPath = rootView.project.relativize(directoryPath)
relativeDirectoryPath = project.relativize(directoryPath)
relativeDirectoryPath += '/' if relativeDirectoryPath.length > 0
dialog = new Dialog
@ -259,7 +258,7 @@ class TreeView extends ScrollView
iconClass: 'add'
onConfirm: (relativePath) =>
endsWithDirectorySeparator = /\/$/.test(relativePath)
path = rootView.project.resolve(relativePath)
path = project.resolve(relativePath)
try
if fs.exists(path)
pathType = if fs.isFile(path) then "file" else "directory"