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.
87 lines (70 loc) • 2.76 kB
JavaScript
Object.defineProperty(exports, '__esModule', {
value: true
});
/*
* 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 _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'); } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _assert2;
function _assert() {
return _assert2 = _interopRequireDefault(require('assert'));
}
var SuggestionList = (function () {
function SuggestionList() {
_classCallCheck(this, SuggestionList);
}
_createClass(SuggestionList, [{
key: 'show',
value: function show(textEditor, suggestion) {
if (!textEditor || !suggestion) {
return;
}
this._textEditor = textEditor;
this._suggestion = suggestion;
this.hide();
var range = suggestion.range;
(0, (_assert2 || _assert()).default)(range);
var _ref = Array.isArray(range) ? range[0] : range;
var position = _ref.start;
this._suggestionMarker = textEditor.markBufferPosition(position);
if (this._suggestionMarker) {
this._overlayDecoration = textEditor.decorateMarker(this._suggestionMarker, {
type: 'overlay',
item: this
});
}
}
}, {
key: 'hide',
value: function hide() {
// $FlowFixMe method override not working with `this`.
atom.views.getView(this).dispose();
if (this._suggestionMarker) {
this._suggestionMarker.destroy();
} else if (this._overlayDecoration) {
this._overlayDecoration.destroy();
}
this._suggestionMarker = undefined;
this._overlayDecoration = undefined;
}
}, {
key: 'getTextEditor',
value: function getTextEditor() {
return this._textEditor;
}
}, {
key: 'getSuggestion',
value: function getSuggestion() {
return this._suggestion;
}
}]);
return SuggestionList;
})();
exports.default = SuggestionList;
module.exports = exports.default;