diff --git a/any-rule-0.0.1.vsix b/any-rule-0.0.1.vsix new file mode 100644 index 0000000..db20767 Binary files /dev/null and b/any-rule-0.0.1.vsix differ diff --git a/out/extension.js b/out/extension.js new file mode 100644 index 0000000..0c01359 --- /dev/null +++ b/out/extension.js @@ -0,0 +1,51 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// The module 'vscode' contains the VS Code extensibility API +// Import the module and reference it with the alias vscode in your code below +const vscode = require("vscode"); +const RULES = require('../packages/www/src/RULES.js'); +// this method is called when your extension is activated +// your extension is activated the very first time the command is executed +function activate(context) { + // Use the console to output diagnostic information (console.log) and errors (console.error) + // This line of code will only be executed once when your extension is activated + console.log('Congratulations, your extension "any-rule" is now active!'); + // The command has been defined in the package.json file + // Now provide the implementation of the command with registerCommand + // The commandId parameter must match the command field in package.json + // let disposable = vscode.commands.registerCommand('extension.helloWorld', () => { + // The code you place here will be executed every time your command is executed + // Display a message box to the user + // vscode.window.showInformationMessage('Hello World123!'); + // }); + // context.subscriptions.push(disposable); + RULES.forEach(({ title, rule }, index) => { + let disposable = vscode.commands.registerCommand(`extension.rule${index}`, () => { + // The code you place here will be executed every time your command is executed + const editor = vscode.window.activeTextEditor; + if (editor) { + const { selections } = editor; + editor.edit(editBuilder => { + selections.forEach(selection => { + const { start, end } = selection; + const range = new vscode.Range(start, end); + editBuilder.replace(range, String(rule)); + }); + }); + // Display a message box to the user + vscode.window.showInformationMessage(`已插入: ${title}`); + } + else { + vscode.window.showWarningMessage('any-rule: 只有在编辑文本的时候才可以使用!'); + } + }); + context.subscriptions.push(disposable); + }); +} +exports.activate = activate; +// this method is called when your extension is deactivated +function deactivate() { + vscode.window.showWarningMessage('any-rule: 已关闭!'); +} +exports.deactivate = deactivate; +//# sourceMappingURL=extension.js.map \ No newline at end of file diff --git a/out/extension.js.map b/out/extension.js.map new file mode 100644 index 0000000..daeee49 --- /dev/null +++ b/out/extension.js.map @@ -0,0 +1 @@ +{"version":3,"file":"extension.js","sourceRo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ACtD;iBAAM;gBACN,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,4BAA4B,CAAC,CAAC;aAC/D;QACF,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AAIJ,CAAC;AA3CD,4BA2CC;AAED,2DAA2D;AAC3D,SAAgB,UAAU;IACzB,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;AACpD,CAAC;AAFD,gCAEC"} \ No newline at end of file diff --git a/out/test/runTest.js b/out/test/runTest.js new file mode 100644 index 0000000..ac4a6ef --- /dev/null +++ b/out/test/runTest.js @@ -0,0 +1,32 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const path = require("path"); +const vscode_test_1 = require("vscode-test"); +function main() { + return __awaiter(this, void 0, void 0, function* () { + try { + // The folder containing the Extension Manifest package.json + // Passed to `--extensionDevelopmentPath` + const extensionDevelopmentPath = path.resolve(__dirname, '../../'); + // The path to test runner + // Passed to --extensionTestsPath + const extensionTestsPath = path.resolve(__dirname, './suite/index'); + // Download VS Code, unzip it and run the integration test + yield vscode_test_1.runTests({ extensionDevelopmentPath, extensionTestsPath }); + } + catch (err) { + console.error('Failed to run tests'); + process.exit(1); + } + }); +} +main(); +//# sourceMappingURL=runTest.js.map \ No newline at end of file diff --git a/out/test/runTest.js.map b/out/test/runTest.js.map new file mode 100644 index 0000000..1bc4921 --- /dev/null +++ b/out/test/runTest.js.map @@ -0,0 +1 @@ +{"version":3,"file":"runTest.js","sourceRoot":"","sources":["../../src/test/runTest.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,6BAA6B;AAE7B,6CAAuC;AAEvC,SAAe,IAAI;;QAClB,IAAI;YACH,4DAA4D;YAC5D,yCAAyC;YACzC,MAAM,wBAAwB,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YAEnE,0BAA0B;YAC1B,iCAAiC;YACjC,MAAM,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;YAEpE,0DAA0D;YAC1D,MAAM,sBAAQ,CAAC,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,CAAC,CAAC;SACjE;QAAC,OAAO,GAAG,EAAE;YACb,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;YACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SAChB;IACF,CAAC;CAAA;AAED,IAAI,EAAE,CAAC"} \ No newline at end of file diff --git a/out/test/suite/extension.test.js b/out/test/suite/extension.test.js new file mode 100644 index 0000000..7f997c2 --- /dev/null +++ b/out/test/suite/extension.test.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const assert = require("assert"); +const mocha_1 = require("mocha"); +// You can import and use all API from the 'vscode' module +// as well as import your extension to test it +const vscode = require("vscode"); +// import * as myExtension from '../extension'; +suite('Extension Test Suite', () => { + mocha_1.before(() => { + vscode.window.showInformationMessage('Start all tests.'); + }); + test('Sample test', () => { + assert.equal(-1, [1, 2, 3].indexOf(5)); + assert.equal(-1, [1, 2, 3].indexOf(0)); + }); +}); +//# sourceMappingURL=extension.test.js.map \ No newline at end of file diff --git a/out/test/suite/extension.test.js.map b/out/test/suite/extension.test.js.map new file mode 100644 index 0000000..c874eac --- /dev/null +++ b/out/test/suite/extension.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"extension.test.js","sourceRoot":"","sources":["../../../src/test/suite/extension.test.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AACjC,iCAA+B;AAE/B,0DAA0D;AAC1D,8CAA8C;AAC9C,iCAAiC;AACjC,+CAA+C;AAE/C,KAAK,CAAC,sBAAsB,EAAE,GAAG,EAAE;IAClC,cAAM,CAAC,GAAG,EAAE;QACX,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,kBAAkB,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,aAAa,EAAE,GAAG,EAAE;QACxB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/out/test/suite/index.js b/out/test/suite/index.js new file mode 100644 index 0000000..ad7cc97 --- /dev/null +++ b/out/test/suite/index.js @@ -0,0 +1,38 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const path = require("path"); +const Mocha = require("mocha"); +const glob = require("glob"); +function run() { + // Create the mocha test + const mocha = new Mocha({ + ui: 'tdd', + }); + mocha.useColors(true); + const testsRoot = path.resolve(__dirname, '..'); + return new Promise((c, e) => { + glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { + if (err) { + return e(err); + } + // Add files to the test suite + files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); + try { + // Run the mocha test + mocha.run(failures => { + if (failures > 0) { + e(new Error(`${failures} tests failed.`)); + } + else { + c(); + } + }); + } + catch (err) { + e(err); + } + }); + }); +} +exports.run = run; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/out/test/suite/index.js.map b/out/test/suite/index.js.map new file mode 100644 index 0000000..9dcec31 --- /dev/null +++ b/out/test/suite/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/test/suite/index.ts"],"names":[],"mappings":";;AAAA,6BAA6B;AAC7B,+BAA+B;AAC/B,6BAA6B;AAE7B,SAAgB,GAAG;IAClB,wBAAwB;IACxB,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC;QACvB,EAAE,EAAE,KAAK;KACT,CAAC,CAAC;IACH,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAEtB,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAEhD,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC3B,IAAI,CAAC,eAAe,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YACxD,IAAI,GAAG,EAAE;gBACR,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;aACd;YAED,8BAA8B;YAC9B,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAE9D,IAAI;gBACH,qBAAqB;gBACrB,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;oBACpB,IAAI,QAAQ,GAAG,CAAC,EAAE;wBACjB,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,QAAQ,gBAAgB,CAAC,CAAC,CAAC;qBAC1C;yBAAM;wBACN,CAAC,EAAE,CAAC;qBACJ;gBACF,CAAC,CAAC,CAAC;aACH;YAAC,OAAO,GAAG,EAAE;gBACb,CAAC,CAAC,GAAG,CAAC,CAAC;aACP;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC;AAhCD,kBAgCC"} \ No newline at end of file