diff --git a/dist/extension.js.map b/dist/extension.js.map index f11fa95..c494e2a 100644 --- a/dist/extension.js.map +++ b/dist/extension.js.map @@ -1 +1 @@ -{"version":3,"file":"extension.js","mappings":"k3BAGAA,EAAAC,SAAA,SAAyBC,GAGvB,IAAIC,EAAaC,EAAOC,SAASC,gBAC/B,sCACA,KAGE,MAAMC,EAASH,EAAOI,OAAOC,iBAC7B,IAAKF,EAEH,YADAH,EAAOI,OAAOE,mBAAmB,2BAKnC,MAAMC,EAAWJ,EAAOI,SAKlBC,EAJOD,EAASE,UAIHC,MAAM,SAGnBC,EAAwB,GACxBC,EAA0B,GAIhC,IAAK,IAAIC,EAAI,EAAGA,EAAIL,EAAMM,OAAQD,IAAK,CAErC,MAAME,EAAcP,EAAMK,GAAGG,OAKvBC,EACJF,EAAYG,WAAW,WAAaH,EAAYG,WAAW,WACvDC,GACHJ,EAAYG,WAAW,QACvBH,EAAYG,WAAW,QACvBH,EAAYG,WAAW,KAGtBD,GAAmBE,IAErBR,EAAYS,KAAKZ,EAAMK,IACvBD,EAAcQ,KAAKP,GAEvB,CAG2B,IAAvBF,EAAYG,QAUhBH,EAAYU,KAAK,CAACC,EAAGC,IAAMD,EAAER,OAASS,EAAET,QAKxCX,EACGqB,KAAMC,IACL,IAAK,IAAIZ,EAAI,EAAGA,EAAID,EAAcE,OAAQD,IAAK,CAE7C,MAAMa,EAAYd,EAAcC,GAC1Bc,EAAYpB,EAASqB,OAAOF,GAAWG,MAI7CJ,EAAYK,QAAQH,EAAWhB,EAAYE,GAC7C,IAEDkB,KAAMC,IACDA,GAEFhC,EAAOI,OAAO6B,uBACZ,uBAAuBtB,EAAYG,uCA7BzCd,EAAOI,OAAO6B,uBACZ,8CAsCRnC,EAAQoC,cAAcd,KAAKrB,EAC7B,EAGAH,EAAAuC,WAAA,WAA8B,EAnG9B,MAAAnC,EAAAoC,EAAAC,EAAA,K,SCAAC,EAAA1C,QAAA2C,QAAA,S,GCCA,MAAAC,EAAA,GCEA,IAAAC,EDCA,SAAAJ,EAAAK,GAEA,MAAAC,EAAAH,EAAAE,GACA,QAAAE,IAAAD,EACA,OAAAA,EAAA/C,QAGA,MAAA0C,EAAAE,EAAAE,GAAA,CAGA9C,QAAA,IAOA,OAHAiD,EAAAH,GAAAI,KAAAR,EAAA1C,QAAA0C,EAAAA,EAAA1C,QAAAyC,GAGAC,EAAA1C,OACA,CCnBAyC,CAAA,K","sources":["webpack://x-sort-impuses/./src/extension.ts","webpack://x-sort-impuses/external commonjs \"vscode\"","webpack://x-sort-impuses/webpack/bootstrap","webpack://x-sort-impuses/webpack/startup"],"sourcesContent":["import * as vscode from \"vscode\";\n\n//\nexport function activate(context: vscode.ExtensionContext) {\n //\n // 1. Register the command that will be triggered by the user\n let disposable = vscode.commands.registerCommand(\n \"x-sort-impuses.sortUsingsAndImports\",\n () => {\n //\n // 2. Get the active text editor\n const editor = vscode.window.activeTextEditor;\n if (!editor) {\n vscode.window.showWarningMessage(\"No active editor found.\");\n return;\n }\n\n //\n const document = editor.document;\n const text = document.getText();\n\n //\n // Split text into lines (handling both Windows \\r\\n and Linux/Mac \\n)\n const lines = text.split(/\\r?\\n/);\n\n //\n const importLines: string[] = [];\n const importIndices: number[] = [];\n\n //\n // 3. Identify all 'using' and 'import' lines\n for (let i = 0; i < lines.length; i++) {\n //\n const trimmedLine = lines[i].trim();\n\n //\n // Check if the line starts with 'using ' or 'import '\n // We also ensure it's not a comment\n const isImportOrUsing =\n trimmedLine.startsWith(\"using \") || trimmedLine.startsWith(\"import \");\n const isNotComment =\n !trimmedLine.startsWith(\"//\") &&\n !trimmedLine.startsWith(\"/*\") &&\n !trimmedLine.startsWith(\"*\");\n\n //\n if (isImportOrUsing && isNotComment) {\n //\n importLines.push(lines[i]); // Store the original line (with its indentation)\n importIndices.push(i); // Store its line number\n }\n }\n\n //\n if (importLines.length === 0) {\n //\n vscode.window.showInformationMessage(\n \"No usings or imports found in this file.\",\n );\n return;\n }\n\n\t //\n // 4. Sort the extracted lines by their length (shortest to longest)\n importLines.sort((a, b) => a.length - b.length);\n\t\n\t //\n // 5. Apply the changes back to the document\n // We use editor.edit() to batch all changes into a single undo/redo action\n editor\n .edit((editBuilder) => {\n for (let i = 0; i < importIndices.length; i++) {\n\t\t\t//\n const lineIndex = importIndices[i];\n const lineRange = document.lineAt(lineIndex).range;\n\n\t\t\t//\n // Replace the original line with the sorted line\n editBuilder.replace(lineRange, importLines[i]);\n }\n })\n .then((success) => {\n if (success) {\n\t\t\t//\n vscode.window.showInformationMessage(\n `Successfully sorted ${importLines.length} imports/usings by length!`,\n );\n }\n });\n },\n );\n\n //\n // 6. Push the disposable to the context's subscriptions\n // so it gets cleaned up when the extension is deactivated\n context.subscriptions.push(disposable);\n}\n\n//\nexport function deactivate() {}\n","module.exports = require(\"vscode\");","// The module cache\nconst __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tconst cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tconst module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nlet __webpack_exports__ = __webpack_require__(265);\n"],"names":["exports","activate","context","disposable","vscode","commands","registerCommand","editor","window","activeTextEditor","showWarningMessage","document","lines","getText","split","importLines","importIndices","i","length","trimmedLine","trim","isImportOrUsing","startsWith","isNotComment","push","sort","a","b","edit","editBuilder","lineIndex","lineRange","lineAt","range","replace","then","success","showInformationMessage","subscriptions","deactivate","__importStar","__webpack_require__","module","require","__webpack_module_cache__","__webpack_exports__","moduleId","cachedModule","undefined","__webpack_modules__","call"],"sourceRoot":""} \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C,QAGA,MAAA0C,EAAAE,EAAAE,GAAA,CAGA9C,QAAA,IAOA,OAHAiD,EAAAH,GAAAI,KAAAR,EAAA1C,QAAA0C,EAAAA,EAAA1C,QAAAyC,GAGAC,EAAA1C,OACA,CCnBAyC,CAAA,K","sources":["webpack://x-sort-impuses/./src/extension.ts","webpack://x-sort-impuses/external commonjs \"vscode\"","webpack://x-sort-impuses/webpack/bootstrap","webpack://x-sort-impuses/webpack/startup"],"sourcesContent":["import * as vscode from \"vscode\";\r\n\r\n//\r\nexport function activate(context: vscode.ExtensionContext) {\r\n //\r\n // 1. Register the command that will be triggered by the user\r\n let disposable = vscode.commands.registerCommand(\r\n \"x-sort-impuses.sortUsingsAndImports\",\r\n () => {\r\n //\r\n // 2. Get the active text editor\r\n const editor = vscode.window.activeTextEditor;\r\n if (!editor) {\r\n vscode.window.showWarningMessage(\"No active editor found.\");\r\n return;\r\n }\r\n\r\n //\r\n const document = editor.document;\r\n const text = document.getText();\r\n\r\n //\r\n // Split text into lines (handling both Windows \\r\\n and Linux/Mac \\n)\r\n const lines = text.split(/\\r?\\n/);\r\n\r\n //\r\n const importLines: string[] = [];\r\n const importIndices: number[] = [];\r\n\r\n //\r\n // 3. Identify all 'using' and 'import' lines\r\n for (let i = 0; i < lines.length; i++) {\r\n //\r\n const trimmedLine = lines[i].trim();\r\n\r\n //\r\n // Check if the line starts with 'using ' or 'import '\r\n // We also ensure it's not a comment\r\n const isImportOrUsing =\r\n trimmedLine.startsWith(\"using \") || trimmedLine.startsWith(\"import \");\r\n const isNotComment =\r\n !trimmedLine.startsWith(\"//\") &&\r\n !trimmedLine.startsWith(\"/*\") &&\r\n !trimmedLine.startsWith(\"*\");\r\n\r\n //\r\n if (isImportOrUsing && isNotComment) {\r\n //\r\n importLines.push(lines[i]); // Store the original line (with its indentation)\r\n importIndices.push(i); // Store its line number\r\n }\r\n }\r\n\r\n //\r\n if (importLines.length === 0) {\r\n //\r\n vscode.window.showInformationMessage(\r\n \"No usings or imports found in this file.\",\r\n );\r\n return;\r\n }\r\n\r\n\t //\r\n // 4. Sort the extracted lines by their length (shortest to longest)\r\n importLines.sort((a, b) => a.length - b.length);\r\n\t\r\n\t //\r\n // 5. Apply the changes back to the document\r\n // We use editor.edit() to batch all changes into a single undo/redo action\r\n editor\r\n .edit((editBuilder) => {\r\n for (let i = 0; i < importIndices.length; i++) {\r\n\t\t\t//\r\n const lineIndex = importIndices[i];\r\n const lineRange = document.lineAt(lineIndex).range;\r\n\r\n\t\t\t//\r\n // Replace the original line with the sorted line\r\n editBuilder.replace(lineRange, importLines[i]);\r\n }\r\n })\r\n .then((success) => {\r\n if (success) {\r\n\t\t\t//\r\n vscode.window.showInformationMessage(\r\n `Successfully sorted ${importLines.length} imports/usings by length!`,\r\n );\r\n }\r\n });\r\n },\r\n );\r\n\r\n //\r\n // 6. Push the disposable to the context's subscriptions\r\n // so it gets cleaned up when the extension is deactivated\r\n context.subscriptions.push(disposable);\r\n}\r\n\r\n//\r\nexport function deactivate() {}\r\n","module.exports = require(\"vscode\");","// The module cache\nconst __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tconst cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tconst module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nlet __webpack_exports__ = __webpack_require__(265);\n"],"names":["exports","activate","context","disposable","vscode","commands","registerCommand","editor","window","activeTextEditor","showWarningMessage","document","lines","getText","split","importLines","importIndices","i","length","trimmedLine","trim","isImportOrUsing","startsWith","isNotComment","push","sort","a","b","edit","editBuilder","lineIndex","lineRange","lineAt","range","replace","then","success","showInformationMessage","subscriptions","deactivate","__importStar","__webpack_require__","module","require","__webpack_module_cache__","__webpack_exports__","moduleId","cachedModule","undefined","__webpack_modules__","call"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index ffd7376..ae755a7 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,9 @@ "displayName": "x-sort-impuses", "description": "an Extension to Sort Import(s) / Using(s) ", "version": "0.0.1", + "publisher": "hadi-khazaei-asl", "engines": { - "vscode": "^1.136.0" + "vscode": "^1.80.0" }, "categories": [ "Other" @@ -34,6 +35,7 @@ "compile": "webpack", "watch": "webpack --watch", "package": "webpack --mode production --devtool hidden-source-map", + "repack": "vsce package", "compile-tests": "tsc -p . --outDir out", "watch-tests": "tsc -p . -w --outDir out", "pretest": "npm run compile-tests && npm run compile && npm run lint", @@ -41,7 +43,7 @@ "test": "vscode-test" }, "devDependencies": { - "@types/vscode": "^1.136.0", + "@types/vscode": "^1.80.0", "@types/mocha": "^10.0.10", "@types/node": "24.x", "typescript-eslint": "^8.61.1",