alm
Version:
The best IDE for TypeScript
81 lines (80 loc) • 3.99 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var socketClient_1 = require("../../../socket/socketClient");
var ui = require("../../ui");
var utils = require("../../../common/utils");
var monacoUtils = require("../monacoUtils");
var state = require("../../state/state");
var selectListView = require("../../selectListView");
var React = require("react");
var csx = require("../../base/csx");
var CommonEditorRegistry = monaco.CommonEditorRegistry;
var EditorAction = monaco.EditorAction;
var KeyMod = monaco.KeyMod;
var KeyCode = monaco.KeyCode;
var EditorContextKeys = monaco.EditorContextKeys;
var GotoTypeScriptSymbolAction = /** @class */ (function (_super) {
__extends(GotoTypeScriptSymbolAction, _super);
function GotoTypeScriptSymbolAction() {
return _super.call(this, {
id: 'editor.action.gotoTypeScriptSymbol',
label: 'Goto TypeScript Symbol (Hieroglyph) in file',
alias: 'Goto TypeScript Symbol (Hieroglyph) in file',
precondition: EditorContextKeys.Writable,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_H
}
}) || this;
}
GotoTypeScriptSymbolAction.prototype.run = function (accessor, editor) {
var filePath = editor.filePath;
if (!state.inActiveProjectFilePath(filePath)) {
ui.notifyInfoNormalDisappear('The current file is no in the active project');
return;
}
socketClient_1.server.getNavigateToItemsForFilePath({ filePath: filePath }).then(function (res) {
if (!res.items) {
ui.notifyInfoNormalDisappear('No TypeScript symbols found for file');
return; // potentially show a message
}
selectListView.selectListView.show({
header: "TypeScript symbols (Hieroglyphs) in " + utils.getFileName(filePath),
data: res.items,
render: function (symbol, matched) {
// NOTE: Code duplicated in `omniSearch.tsx` (except this needs to set font explicitly)
var color = ui.kindToColor(symbol.kind);
var icon = ui.kindToIcon(symbol.kind);
return (React.createElement("div", { style: { fontFamily: 'monospace' } },
React.createElement("div", { style: csx.horizontal },
React.createElement("span", null, matched),
React.createElement("span", { style: csx.flex }),
React.createElement("strong", { style: { color: color } }, symbol.kind),
"\u00A0",
React.createElement("span", { style: csx.extend({ color: color, fontFamily: 'FontAwesome' }) }, icon)),
React.createElement("div", null,
symbol.fileName,
":",
symbol.position.line + 1)));
},
textify: function (item) { return item.name; },
onSelect: function (item) {
monacoUtils.gotoPosition({ editor: editor, position: item.position });
return '';
}
});
});
};
return GotoTypeScriptSymbolAction;
}(EditorAction));
CommonEditorRegistry.registerEditorAction(new GotoTypeScriptSymbolAction());