 
     deferred.promise
 
+  ###
+  Section: Private
+  ###
+
+  # Given a path to a file, this constructs and associates a new
+  # {Editor}, showing the file.
+  #
+  # * `filePath` The {String} path of the file to associate with.
+  # * `options` Options that you can pass to the {Editor} constructor.
+  #
+  # Returns a promise that resolves to an {Editor}.
+  open: (filePath, options={}) ->
+    filePath = @resolve(filePath)
+    @bufferForPath(filePath).then (buffer) =>
+      @buildEditorForBuffer(buffer, options)
+
+  # Deprecated
+  openSync: (filePath, options={}) ->
+    deprecate("Use Project::open instead")
+    filePath = @resolve(filePath)
+    @buildEditorForBuffer(@bufferForPathSync(filePath), options)
+
+  # Retrieves all the {TextBuffer}s in the project; that is, the
+  # buffers for all open files.
+  #
+  # Returns an {Array} of {TextBuffer}s.
+  getBuffers: ->
+    @buffers.slice()
+
+  # Is the buffer for the given path modified?
+  isPathModified: (filePath) ->
+    @findBufferForPath(@resolve(filePath))?.isModified()
+
+  findBufferForPath: (filePath) ->
+    _.find @buffers, (buffer) -> buffer.getPath() == filePath
+
+  # Only to be used in specs
+  bufferForPathSync: (filePath) ->
+    absoluteFilePath = @resolve(filePath)
+    existingBuffer = @findBufferForPath(absoluteFilePath) if filePath
+    existingBuffer ? @buildBufferSync(absoluteFilePath)
+
+  # Given a file path, this retrieves or creates a new {TextBuffer}.
+  #
+  # If the `filePath` already has a `buffer`, that value is used instead. Otherwise,
+  # `text` is used as the contents of the new buffer.
+  #
+  # * `filePath` A {String} representing a path. If `null`, an "Untitled" buffer is created.
+  #
+  # Returns a promise that resolves to the {TextBuffer}.
+  bufferForPath: (filePath) ->
+    absoluteFilePath = @resolve(filePath)
+    existingBuffer = @findBufferForPath(absoluteFilePath) if absoluteFilePath
+    Q(existingBuffer ? @buildBuffer(absoluteFilePath))
+
+  bufferForId: (id) ->
+    _.find @buffers, (buffer) -> buffer.id is id
+
+  # Still needed when deserializing a tokenized buffer
+  buildBufferSync: (absoluteFilePath) ->
+    buffer = new TextBuffer({filePath: absoluteFilePath})
+    @addBuffer(buffer)
+    buffer.loadSync()
+    buffer
+
+  # Given a file path, this sets its {TextBuffer}.
+  #
+  # * `absoluteFilePath` A {String} representing a path.
+  # * `text` The {String} text to use as a buffer.
+  #
+  # Returns a promise that resolves to the {TextBuffer}.
+  buildBuffer: (absoluteFilePath) ->
+    if fs.getSizeSync(absoluteFilePath) >= 2 * 1048576 # 2MB
+      throw new Error("Atom can only handle files < 2MB for now.")
+
+    buffer = new TextBuffer({filePath: absoluteFilePath})
+    @addBuffer(buffer)
+    buffer.load()
+      .then((buffer) -> buffer)
+      .catch(=> @removeBuffer(buffer))
+
+  addBuffer: (buffer, options={}) ->
+    @addBufferAtIndex(buffer, @buffers.length, options)
+    buffer.onDidDestroy => @removeBuffer(buffer)
+
+  addBufferAtIndex: (buffer, index, options={}) ->
+    @buffers.splice(index, 0, buffer)
+    buffer.onDidDestroy => @removeBuffer(buffer)
+    @emit 'buffer-created', buffer
+    buffer
+
+  # Removes a {TextBuffer} association from the project.
+  #
+  # Returns the removed {TextBuffer}.
+  removeBuffer: (buffer) ->
+    index = @buffers.indexOf(buffer)
+    @removeBufferAtIndex(index) unless index is -1
+
+  removeBufferAtIndex: (index, options={}) ->
+    [buffer] = @buffers.splice(index, 1)
+    buffer?.destroy()
+
   buildEditorForBuffer: (buffer, editorOptions) ->
     editor = new Editor(_.extend({buffer, registerEditor: true}, editorOptions))
     editor

  destroyUnretainedBuffers: ->
    buffer.destroy() for buffer in @getBuffers() when not buffer.isRetained()

  # Public: Returns the {Git} repository if available.
  getRepo: -> @repo

  # Public: Returns the project's {String} fullpath.
  getPath: ->

  contains: (pathToCheck) ->
    @rootDirectory?.contains(pathToCheck) ? false

  ###
  Section: Searching and Replacing
  ###

  # Public: Performs a search across all the files in the project.
  #
