alm
Version:
The best IDE for TypeScript
48 lines (47 loc) • 2.01 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 uix = require("../../uix");
var CommonEditorRegistry = monaco.CommonEditorRegistry;
var EditorAction = monaco.EditorAction;
var EditorContextKeys = monaco.EditorContextKeys;
/* Test:
<!-- Hello world -->
<div class="awesome" style="border: 1px solid red">
<label for="name">Enter your name: </label>
<input type="text" id="name" />
</div>
<p>Enter your HTML here</p>
*/
var RemoveUnusedImportsAction = /** @class */ (function (_super) {
__extends(RemoveUnusedImportsAction, _super);
function RemoveUnusedImportsAction() {
return _super.call(this, {
id: 'editor.action.removeUnusedImports',
label: 'Remove unused imports',
alias: 'Remove unused imports',
precondition: EditorContextKeys.Writable,
}) || this;
}
RemoveUnusedImportsAction.prototype.run = function (accessor, editor) {
var filePath = editor.filePath;
var selection = editor.getSelection();
socketClient_1.server.removeUnusedImports({ filePath: editor.filePath }).then(function (refactorings) {
// apply refactorings
// console.log('Apply refactorings:', refactorings); // DEBUG
uix.API.applyRefactorings(refactorings);
});
};
return RemoveUnusedImportsAction;
}(EditorAction));
CommonEditorRegistry.registerEditorAction(new RemoveUnusedImportsAction());