   #
   # Returns a String.
   resolve: (uri) ->
+    return uri unless uri?
+
     if uri?.match(/[A-Za-z0-9+-.]+:\/\//) # leave path alone if it has a scheme
       uri
     else


  # Private: DEPRECATED
  bufferForPath: (filePath, text) ->
    if filePath?
      filePath = @resolve(filePath)
      if filePath
        buffer = _.find @buffers, (buffer) -> buffer.getPath() == filePath
        buffer or @buildBuffer(filePath, text)
    else
      @buildBuffer(null, text)

  # Private: Given a file path, this retrieves or creates a new {TextBuffer}.
  #

  #
  # Returns a promise that resolves to the {TextBuffer}.
  bufferForPathAsync: (filePath, text) ->
    absoluteFilePath = @resolve(filePath)
    if absoluteFilePath
      existingBuffer = _.find @buffers, (buffer) -> buffer.getPath() == absoluteFilePath

    Q(existingBuffer ? @buildBuffer(absoluteFilePath, text))

  # Private:
  bufferForId: (id) ->
    _.find @buffers, (buffer) -> buffer.id is id

  # Private: DEPRECATED
  buildBuffer: (absoluteFilePath, initialText) ->
    buffer = new TextBuffer({project: this, filePath: absoluteFilePath, initialText})
    buffer.load()
    @addBuffer(buffer)
    buffer

  # Private: Given a file path, this sets its {TextBuffer}.
  #
