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.
67 lines (51 loc) • 3.32 kB
JavaScript
var _createDecoratedClass = (function () { function defineProperties(target, descriptors, initializers) { for (var i = 0; i < descriptors.length; i++) { var descriptor = descriptors[i]; var decorators = descriptor.decorators; var key = descriptor.key; delete descriptor.key; delete descriptor.decorators; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor || descriptor.initializer) descriptor.writable = true; if (decorators) { for (var f = 0; f < decorators.length; f++) { var decorator = decorators[f]; if (typeof decorator === 'function') { descriptor = decorator(target, key, descriptor) || descriptor; } else { throw new TypeError('The decorator for method ' + descriptor.key + ' is of the invalid type ' + typeof decorator); } } if (descriptor.initializer !== undefined) { initializers[key] = descriptor; continue; } } Object.defineProperty(target, key, descriptor); } } return function (Constructor, protoProps, staticProps, protoInitializers, staticInitializers) { if (protoProps) defineProperties(Constructor.prototype, protoProps, protoInitializers); if (staticProps) defineProperties(Constructor, staticProps, staticInitializers); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
/*
* 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 _assert2;
function _assert() {
return _assert2 = _interopRequireDefault(require('assert'));
}
var _nuclideAnalytics2;
function _nuclideAnalytics() {
return _nuclideAnalytics2 = require('../../nuclide-analytics');
}
var _FlowServiceFactory2;
function _FlowServiceFactory() {
return _FlowServiceFactory2 = require('./FlowServiceFactory');
}
var FlowAutocompleteProvider = (function () {
function FlowAutocompleteProvider() {
_classCallCheck(this, FlowAutocompleteProvider);
}
_createDecoratedClass(FlowAutocompleteProvider, [{
key: 'getSuggestions',
decorators: [(0, (_nuclideAnalytics2 || _nuclideAnalytics()).trackTiming)('flow.autocomplete')],
value: function getSuggestions(request) {
var editor = request.editor;
var prefix = request.prefix;
var activatedManually = request.activatedManually;
var filePath = editor.getPath();
var contents = editor.getText();
var cursor = editor.getLastCursor();
var line = cursor.getBufferRow();
var col = cursor.getBufferColumn();
if (filePath == null) {
return Promise.resolve(null);
}
var flowService = (0, (_FlowServiceFactory2 || _FlowServiceFactory()).getFlowServiceByNuclideUri)(filePath);
(0, (_assert2 || _assert()).default)(flowService);
return flowService.flowGetAutocompleteSuggestions(filePath, contents, line, col, prefix,
// Needs to be a boolean, but autocomplete-plus gives us undefined instead of false.
Boolean(activatedManually));
}
}]);
return FlowAutocompleteProvider;
})();
module.exports = FlowAutocompleteProvider;