UNPKG

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.

83 lines (62 loc) 2.69 kB
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { var callNext = step.bind(null, 'next'); var callThrow = step.bind(null, 'throw'); function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(callNext, callThrow); } } callNext(); }); }; } /* * 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. */ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _commonsNodeNuclideUri2; function _commonsNodeNuclideUri() { return _commonsNodeNuclideUri2 = _interopRequireDefault(require('../../commons-node/nuclideUri')); } var _assert2; function _assert() { return _assert2 = _interopRequireDefault(require('assert')); } var _constants2; function _constants() { return _constants2 = require('./constants'); } var _commonsAtomGoToLocation2; function _commonsAtomGoToLocation() { return _commonsAtomGoToLocation2 = require('../../commons-atom/go-to-location'); } var _nuclideRemoteConnection2; function _nuclideRemoteConnection() { return _nuclideRemoteConnection2 = require('../../nuclide-remote-connection'); } var EXTENSIONS = new Set(['ml', 'mli']); module.exports = { priority: 20, providerName: 'nuclide-ocaml', getSuggestionForWord: _asyncToGenerator(function* (textEditor, text, range) { if (!(_constants2 || _constants()).GRAMMARS.has(textEditor.getGrammar().scopeName)) { return null; } var file = textEditor.getPath(); if (file == null) { return null; } var kind = 'ml'; var extension = (_commonsNodeNuclideUri2 || _commonsNodeNuclideUri()).default.extname(file); if (EXTENSIONS.has(extension)) { kind = extension; } var instance = yield (0, (_nuclideRemoteConnection2 || _nuclideRemoteConnection()).getServiceByNuclideUri)('MerlinService', file); (0, (_assert2 || _assert()).default)(instance); var start = range.start; return { range: range, callback: _asyncToGenerator(function* () { yield instance.pushNewBuffer(file, textEditor.getText()); var location = yield instance.locate(file, start.row, start.column, kind); if (!location) { return; } (0, (_commonsAtomGoToLocation2 || _commonsAtomGoToLocation()).goToLocation)(location.file, location.pos.line - 1, location.pos.col); }) }; }) };