     catch error
       switch error.code
         when 'CANCELLED'
-          return Q()
+          return Promise.resolve()
         when 'EACCES'
           atom.notifications.addWarning("Permission denied '#{error.path}'")
-          return Q()
+          return Promise.resolve()
         when 'EPERM', 'EBUSY', 'ENXIO', 'EIO', 'ENOTCONN', 'UNKNOWN', 'ECONNRESET', 'EINVAL'
           atom.notifications.addWarning("Unable to open '#{error.path ? uri}'", detail: error.message)
-          return Q()
+          return Promise.resolve()
         else
           throw error
 
-    Q(item)
+    Promise.resolve(item)
       .then (item) =>
         if not pane
           pane = new Pane(items: [item])

    if uri = @destroyedItemURIs.pop()
      @open(uri)
    else
      Q()

  # Public: Register an opener for a uri.
  #

  #
  # Returns a `Promise`.
  replace: (regex, replacementText, filePaths, iterator) ->
    new Promise (resolve, reject) =>
      openPaths = (buffer.getPath() for buffer in atom.project.getBuffers())
      outOfProcessPaths = _.difference(filePaths, openPaths)

      inProcessFinished = not openPaths.length
      outOfProcessFinished = not outOfProcessPaths.length
      checkFinished = ->
        resolve() if outOfProcessFinished and inProcessFinished

      unless outOfProcessFinished.length
        flags = 'g'
        flags += 'i' if regex.ignoreCase

        task = Task.once require.resolve('./replace-handler'), outOfProcessPaths, regex.source, flags, replacementText, ->
          outOfProcessFinished = true
          checkFinished()

        task.on 'replace:path-replaced', iterator
        task.on 'replace:file-error', (error) -> iterator(null, error)

      for buffer in atom.project.getBuffers()
        continue unless buffer.getPath() in filePaths
        replacements = buffer.replace(regex, replacementText, iterator)
        iterator({filePath: buffer.getPath(), replacements}) if replacements

      inProcessFinished = true
      checkFinished()

if includeDeprecatedAPIs
  Workspace.properties
