atom-nuclide
Version:
A unified developer experience for web and mobile development, built as a suite of features on top of Atom to provide hackability and the support of an active community.
57 lines (48 loc) • 2.44 kB
JavaScript
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
/*
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the LICENSE file in
* the root directory of this source tree.
*/
var _nuclideRemoteConnection2;
function _nuclideRemoteConnection() {
return _nuclideRemoteConnection2 = require('../../nuclide-remote-connection');
}
/**
* The prefix a URI must have for `RemoteDirectoryProvider` to try to produce a
* `RemoteDirectory` for it. This should also be the path prefix checked by the
* handler we register with `atom.project.registerOpener()` to open remote files.
*/
var REMOTE_PATH_URI_PREFIX = 'nuclide://';
var RemoteDirectoryProvider = (function () {
function RemoteDirectoryProvider() {
_classCallCheck(this, RemoteDirectoryProvider);
}
_createClass(RemoteDirectoryProvider, [{
key: 'directoryForURISync',
value: function directoryForURISync(uri) {
if (!uri.startsWith(REMOTE_PATH_URI_PREFIX)) {
return null;
}
var connection = (_nuclideRemoteConnection2 || _nuclideRemoteConnection()).RemoteConnection.getForUri(uri);
if (connection) {
return connection.createDirectory(uri);
} else {
// Return null here. In response, Atom will create a generic Directory for
// this URI, and add it to the list of root project paths (atom.project.getPaths()).
// In remote-projects/main.js, we remove these generic directories.
return null;
}
}
}, {
key: 'directoryForURI',
value: function directoryForURI(uri) {
return Promise.resolve(this.directoryForURISync(uri));
}
}]);
return RemoteDirectoryProvider;
})();
module.exports = RemoteDirectoryProvider;