Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
bad03a6074 | |||
076553967c | |||
33d743afc7 | |||
8f8ae89be5 | |||
c50dfe4f70 | |||
3ff4c068f2 | |||
c930475fac | |||
5d5bccbf6f | |||
5290684660 | |||
2ed3b1c8a0 | |||
29d892f666 |
26
.editorconfig
Normal file
26
.editorconfig
Normal file
@@ -0,0 +1,26 @@
|
||||
# EditorConfig is awesome: https://editorconfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
|
||||
# Unix-style newlines with a newline ending every file
|
||||
insert_final_newline = true
|
||||
|
||||
# Set default charset
|
||||
charset = utf-8
|
||||
|
||||
[*.{js,ts}]
|
||||
# 4 space indentation
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
# Tab indentation (no size specified)
|
||||
[.vscode/**.json]
|
||||
indent_style = tab
|
||||
|
||||
# 历史原因需要保留 tab 缩进的代码文件
|
||||
[src/{test/extension.test.ts,extension.ts}]
|
||||
indent_style = tab
|
@@ -1,30 +0,0 @@
|
||||
{
|
||||
"root": true,
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 6,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/naming-convention": [
|
||||
"warn",
|
||||
{
|
||||
"selector": "import",
|
||||
"format": [ "camelCase", "PascalCase" ]
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/semi": "warn",
|
||||
"curly": "warn",
|
||||
"eqeqeq": "warn",
|
||||
"no-throw-literal": "warn",
|
||||
"semi": "off"
|
||||
},
|
||||
"ignorePatterns": [
|
||||
"out",
|
||||
"dist",
|
||||
"**/*.d.ts"
|
||||
]
|
||||
}
|
2
.vscode/extensions.json
vendored
2
.vscode/extensions.json
vendored
@@ -3,6 +3,6 @@
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"dbaeumer.vscode-eslint",
|
||||
"ms-vscode.extension-test-runner"
|
||||
"ms-vscode.extension-test-runner"
|
||||
]
|
||||
}
|
||||
|
18
.vscode/settings.json
vendored
18
.vscode/settings.json
vendored
@@ -1,11 +1,11 @@
|
||||
// Place your settings in this file to overwrite default and user settings.
|
||||
{
|
||||
"files.exclude": {
|
||||
"out": false // set this to true to hide the "out" folder with the compiled JS files
|
||||
},
|
||||
"search.exclude": {
|
||||
"out": true // set this to false to include "out" folder in search results
|
||||
},
|
||||
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
|
||||
"typescript.tsc.autoDetect": "off"
|
||||
}
|
||||
"files.exclude": {
|
||||
"out": false // set this to true to hide the "out" folder with the compiled JS files
|
||||
},
|
||||
"search.exclude": {
|
||||
"out": true // set this to false to include "out" folder in search results
|
||||
},
|
||||
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
|
||||
"typescript.tsc.autoDetect": "off"
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ src/**
|
||||
.yarnrc
|
||||
vsc-extension-quickstart.md
|
||||
**/tsconfig.json
|
||||
**/.eslintrc.json
|
||||
**/eslint.config.mjs
|
||||
**/*.map
|
||||
**/*.ts
|
||||
**/.vscode-test.*
|
||||
|
19
CHANGELOG.md
19
CHANGELOG.md
@@ -21,8 +21,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Removed
|
||||
|
||||
### Internal
|
||||
|
||||
-->
|
||||
|
||||
## 2.1.0
|
||||
|
||||
### Changed
|
||||
|
||||
- **[BREAKING!!!]** Deprecate `variable-conversion.disableFormat`, please use `variable-conversion.enabledFormats` instead. (移除 `variable-conversion.disableFormat` 配置项,请使用 `variable-conversion.enabledFormats`)
|
||||
- Support enabling only partial target conversion formats. (支持仅开启部分目标转换格式)
|
||||
|
||||
## 2.0.1
|
||||
|
||||
### Internal
|
||||
|
||||
- Add `.editorconfig` file. (添加 `.editorconfig` 文件)
|
||||
- Upgrade plugin dependency versions. (升级插件依赖版本)
|
||||
- Modify eslint configuration. (调整 eslint 配置)
|
||||
|
||||
## 2.0.0
|
||||
|
||||
### Added
|
||||
@@ -110,4 +127,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Adds an editor context menu with submenu
|
||||
- Implement conversion to Camel Case, Pascal Case, Snake Case(Snake Camel, Snake Pascal, Snake Upper), Kebab Case(Kebab Camel, Kebab Pascal, Kebab Upper), Lower Case, Upper Case
|
||||
- Add test cases
|
||||
- Initial release
|
||||
- Initial release
|
||||
|
19
README.md
19
README.md
@@ -5,14 +5,20 @@
|
||||
一个强大的变量命名及路径风格转换插件,支持一键转换、循环转换,支持右键菜单、快捷键、状态栏等多种方式使用。<br>
|
||||
A powerful variable and path conversion extension. Supports one-key conversion & cyclic conversion. You can use it through the editer menu, shortcut keys and status bar.
|
||||
|
||||
> 【近期更新】v2.0.0 版本 (2024-12-15)
|
||||
> **【近期更新】**
|
||||
>
|
||||
> **v2.1.0 (2025-07-14)**
|
||||
>
|
||||
> - 支持仅开启部分目标转换格式 (优化 VSCode 配置项)
|
||||
>
|
||||
> **v2.0.0 (2024-12-15)**
|
||||
>
|
||||
> - 支持 Windows / Unix 路径风格转换(可选中文本中的路径,然后使用 `Ctrl + Alt + /` 快捷键,或点击右键菜单、底部状态栏路径转换按钮轻松实现转换)
|
||||
|
||||
- ✅ 支持多选区 Support multi-selection
|
||||
- ✅ 支持多窗口 Support subwindow
|
||||
- ✅ 支持撤回 & 重做 Support undo & redo (Ctrl + Z / Ctrl + Y)
|
||||
- ✅ 支持禁用部分目标转换格式 Supports disabling some target conversion formats
|
||||
- ✅ 支持仅开启部分目标转换格式 Support enabling only partial target conversion formats
|
||||
|
||||
> 🔭 Tips for Chinese users: 如果您无法看到下文图片,请[点这里](https://gitee.com/coder-xiaomo/variable-conversion-vscode-extension/blob/main/README.md)查看
|
||||
|
||||
@@ -67,7 +73,7 @@ Or right-click on the selected text -> Convert string to...
|
||||
|
||||

|
||||
|
||||
**注:**目前 `v2.0.0` 版本暂仅支持 `Windows 风格路径` 与 `Unix 风格路径` 互转,所以这两个快捷键目前效果相同。**后续会陆续增加其他更多路径风格**(例如 `Windows Git Bash` 风格,浏览器 `file://` 协议风格等),敬请期待。
|
||||
**注:** 目前 `v2.0.0` 版本暂仅支持 `Windows 风格路径` 与 `Unix 风格路径` 互转,所以这两个快捷键目前效果相同。**后续会陆续增加其他更多路径风格**(例如 `Windows Git Bash` 风格,浏览器 `file://` 协议风格等),敬请期待。
|
||||
|
||||
## 快捷键 Shortcut key
|
||||
|
||||
@@ -84,9 +90,10 @@ Or right-click on the selected text -> Convert string to...
|
||||
|
||||
## 配置项 Configurations
|
||||
|
||||
| 配置项 Configuration Key | 描述 Description | 配置示例 | 默认值 |
|
||||
| ----------------------------------- | ------------------------------------------------------------ | ------------------------------ | ------ |
|
||||
| `variable-conversion.disableFormat` | 定义哪些格式是禁用的<br />Define which formats are disabled. | `["lower_case", "upper_case"]` | `[]` |
|
||||
| 配置项 Configuration Key | 描述 Description | 配置示例 | 默认值 |
|
||||
| --------------------------------------- | ------------------------------------------------------------ | ------------------------------------- | -------- |
|
||||
| `variable-conversion.enabledFormats` | 配置启用的变量命名方式<br />Configuration of Enabled Variable Naming Conventions. | `{ "xxxCase.enabled": boolean, ... }` | 见配置项 |
|
||||
| `variable-conversion.disablePathFormat` | 定义哪些路径风格是禁用的<br />Define which path formats are disabled. | `["windows_style", "unix_style"]` | 见配置项 |
|
||||
|
||||
## 支持的类型 Support Case
|
||||
|
||||
|
28
eslint.config.mjs
Normal file
28
eslint.config.mjs
Normal file
@@ -0,0 +1,28 @@
|
||||
import typescriptEslint from "@typescript-eslint/eslint-plugin";
|
||||
import tsParser from "@typescript-eslint/parser";
|
||||
|
||||
export default [{
|
||||
files: ["**/*.ts"],
|
||||
}, {
|
||||
plugins: {
|
||||
"@typescript-eslint": typescriptEslint,
|
||||
},
|
||||
|
||||
languageOptions: {
|
||||
parser: tsParser,
|
||||
ecmaVersion: 2022,
|
||||
sourceType: "module",
|
||||
},
|
||||
|
||||
rules: {
|
||||
"@typescript-eslint/naming-convention": ["warn", {
|
||||
selector: "import",
|
||||
format: ["camelCase", "PascalCase"],
|
||||
}],
|
||||
|
||||
curly: "warn",
|
||||
eqeqeq: "warn",
|
||||
"no-throw-literal": "warn",
|
||||
semi: "warn",
|
||||
},
|
||||
}];
|
2214
package-lock.json
generated
2214
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
160
package.json
160
package.json
@@ -2,11 +2,11 @@
|
||||
"name": "variable-conversion",
|
||||
"displayName": "Variable Conversion",
|
||||
"description": "一个强大的变量名转换插件,支持右键菜单、快捷键、状态栏等多种方式使用,支持小驼峰、大驼峰(帕斯卡)、下划线(蛇形)、中划线(连字符/脊柱式)、空格分隔、点分隔、全小写、全大写等常用命名方式(及组合)转换。 \nA powerful variable naming conversion extension. You can use it through the editer menu, shortcut keys and bottom bar. Support camel, pascal, snake, kebab(spinal), space, dot, lower, upper case, and more.",
|
||||
"version": "2.0.0",
|
||||
"version": "2.1.0",
|
||||
"icon": "image/logo.png",
|
||||
"publisher": "coder-xiaomo",
|
||||
"engines": {
|
||||
"vscode": "^1.87.0"
|
||||
"vscode": "^1.102.0"
|
||||
},
|
||||
"categories": [
|
||||
"Other"
|
||||
@@ -324,9 +324,141 @@
|
||||
"configuration": {
|
||||
"title": "Variable Conversion 变量转换",
|
||||
"properties": {
|
||||
"variable-conversion.enabledFormats": {
|
||||
"type": "object",
|
||||
"description": "Tags and options configured here will be used by the Add Tags command to add tags to struct fields. If promptForTags is true, then user will be prompted for tags and options. By default, json tags are added.",
|
||||
"markdownDescription": "配置启用的变量命名方式\n\nConfiguration of Enabled Variable Naming Conventions.\n\n \n\n🌰 e.g. *Mike like eat ice-cream*\n\n对于这个句子,不同命名方式如以下示例:\n\nFor this sentence, different naming conventions are as follows:\n\n[在 settings.json 中编辑 (Edit in settings.json)](command:workbench.action.openSettingsJson)",
|
||||
"scope": "window",
|
||||
"properties": {
|
||||
"lowerCase.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "[全小写命名] lower case (全小写)\n 🌰e.g. mike like eat ice-cream"
|
||||
},
|
||||
"snakeCase.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "[全小写命名] snake case (下划线)\n 🌰e.g. mike_like_eat_ice_cream"
|
||||
},
|
||||
"kebabCase.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "[全小写命名] kebab case (连字符)\n 🌰e.g. mike-like-eat-ice-cream"
|
||||
},
|
||||
"spaceCase.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "[全小写命名] space case (空格)\n 🌰e.g. mike like eat ice cream"
|
||||
},
|
||||
"dotCase.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "[全小写命名] dot case (点)\n 🌰e.g. mike.like.eat.ice.cream"
|
||||
},
|
||||
"upperCase.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "[全大写命名] upper case (全大写)\n 🌰e.g. MIKE LIKE EAT ICE-CREAM"
|
||||
},
|
||||
"snakeUpperCase.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "[全大写命名] snake upper case (下划线)\n 🌰e.g. MIKE_LIKE_EAT_ICE_CREAM"
|
||||
},
|
||||
"kebabUpperCase.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "[全大写命名] kebab upper case (连字符)\n 🌰e.g. MIKE-LIKE-EAT-ICE-CREAM"
|
||||
},
|
||||
"spaceUpperCase.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "[全大写命名] space upper case (空格)\n 🌰e.g. MIKE LIKE EAT ICE CREAM"
|
||||
},
|
||||
"dotUpperCase.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "[全大写命名] dot upper case (点)\n 🌰e.g. MIKE.LIKE.EAT.ICE.CREAM"
|
||||
},
|
||||
"pascalCase.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "[大驼峰命名] pascal case (大驼峰)\n 🌰e.g. MikeLikeEatIceCream"
|
||||
},
|
||||
"snakePascalCase.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "[大驼峰命名] snake pascal case (下划线)\n 🌰e.g. Mike_Like_Eat_Ice_Cream"
|
||||
},
|
||||
"kebabPascalCase.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "[大驼峰命名] kebab pascal case (连字符)\n 🌰e.g. Mike-Like-Eat-Ice-Cream"
|
||||
},
|
||||
"spacePascalCase.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "[大驼峰命名] space pascal case (空格)\n 🌰e.g. Mike Like Eat Ice Cream"
|
||||
},
|
||||
"dotPascalCase.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "[大驼峰命名] dot pascal case (点)\n 🌰e.g. Mike.Like.Eat.Ice.Cream"
|
||||
},
|
||||
"camelCase.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "[小驼峰命名] camel case (小驼峰)\n 🌰e.g. mikeLikeEatIceCream"
|
||||
},
|
||||
"snakeCamelCase.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "[小驼峰命名] snake camel case (下划线)\n 🌰e.g. mike_Like_Eat_Ice_Cream"
|
||||
},
|
||||
"kebabCamelCase.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "[小驼峰命名] kebab camel case (连字符)\n 🌰e.g. mike-Like-Eat-Ice-Cream"
|
||||
},
|
||||
"spaceCamelCase.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "[小驼峰命名] space camel case (空格)\n 🌰e.g. mike Like Eat Ice Cream"
|
||||
},
|
||||
"dotCamelCase.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "[小驼峰命名] dot camel case (点)\n 🌰e.g. mike.Like.Eat.Ice.Cream"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"default": {
|
||||
"lowerCase.enabled": true,
|
||||
"snakeCase.enabled": true,
|
||||
"kebabCase.enabled": true,
|
||||
"spaceCase.enabled": true,
|
||||
"dotCase.enabled": false,
|
||||
"upperCase.enabled": true,
|
||||
"snakeUpperCase.enabled": true,
|
||||
"kebabUpperCase.enabled": false,
|
||||
"spaceUpperCase.enabled": true,
|
||||
"dotUpperCase.enabled": false,
|
||||
"pascalCase.enabled": true,
|
||||
"snakePascalCase.enabled": false,
|
||||
"kebabPascalCase.enabled": false,
|
||||
"spacePascalCase.enabled": false,
|
||||
"dotPascalCase.enabled": false,
|
||||
"camelCase.enabled": true,
|
||||
"snakeCamelCase.enabled": false,
|
||||
"kebabCamelCase.enabled": false,
|
||||
"spaceCamelCase.enabled": false,
|
||||
"dotCamelCase.enabled": false
|
||||
}
|
||||
},
|
||||
"variable-conversion.disableFormat": {
|
||||
"order": 1,
|
||||
"markdownDescription": "定义哪些变量命名方式是禁用的\n\nDefine which variable formats are disabled.\n\n若您感觉以下配置比较麻烦,也可以选择在 `settings.json` 中编辑:\n\nIf you find the following configuration troublesome, you can also edit this configuration item in `settings.json`:\n\n`\"variable-conversion.disableFormat\": [ ... ],`\n\n[在 settings.json 中编辑 (Edit in settings.json)](command:workbench.action.openSettingsJson)\n\n配置后,您可能需要*重启扩展宿主*,或*重启当前窗口*才可使该配置完全生效(二选一即可):\n\nYou may need to *restart extension host* or *reload window* after configuration to take full effect (either):\n\n[重启扩展宿主 (Restart Extension Host)](command:workbench.action.restartExtensionHost), [重启当前窗口 (Reload Window)](command:workbench.action.reloadWindow)",
|
||||
"markdownDeprecationMessage": "**Deprecated**: Please use `#variable-conversion.enabledFormats#` instead.\n\n**已弃用**,请使用 `#variable-conversion.enabledFormats#`。",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
@@ -402,20 +534,20 @@
|
||||
"compile": "tsc -p ./",
|
||||
"watch": "tsc -watch -p ./",
|
||||
"pretest": "npm run compile && npm run lint",
|
||||
"lint": "eslint src --ext ts",
|
||||
"lint": "eslint src",
|
||||
"test": "vscode-test",
|
||||
"package": "echo \"start `vsce package`\" & vsce package",
|
||||
"package": "vsce package",
|
||||
"publish": "vsce publish"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/mocha": "^10.0.6",
|
||||
"@types/node": "18.x",
|
||||
"@types/vscode": "^1.87.0",
|
||||
"@typescript-eslint/eslint-plugin": "^7.4.0",
|
||||
"@typescript-eslint/parser": "^7.4.0",
|
||||
"@vscode/test-cli": "^0.0.8",
|
||||
"@vscode/test-electron": "^2.3.9",
|
||||
"eslint": "^8.57.0",
|
||||
"typescript": "^5.3.3"
|
||||
"@types/mocha": "^10.0.10",
|
||||
"@types/node": "20.x",
|
||||
"@types/vscode": "^1.102.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.31.1",
|
||||
"@typescript-eslint/parser": "^8.31.1",
|
||||
"@vscode/test-cli": "^0.0.11",
|
||||
"@vscode/test-electron": "^2.5.2",
|
||||
"eslint": "^9.25.1",
|
||||
"typescript": "^5.8.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -113,4 +113,4 @@ function replaceTextEditorSelectedText() {
|
||||
});
|
||||
userSelection.lastConvertedSelectionsText = textList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -66,7 +66,7 @@ function lazyConvert() {
|
||||
}
|
||||
|
||||
// 获取用户配置
|
||||
const disableFormatList = getUserConfigurations<Array<string>>('disableFormat') || [];
|
||||
const enabledFormats = getUserConfigurations<Record<string, boolean>>('enabledFormats') || {};
|
||||
|
||||
const textList = userSelection.currentSelectionsText;
|
||||
// vscode.window.showInformationMessage('lazyConvert' + textList.join('\n'));
|
||||
@@ -75,7 +75,7 @@ function lazyConvert() {
|
||||
for (const cyclicConvertCase of cyclicConvertCaseOrder) {
|
||||
// issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1
|
||||
// 跳过禁用的目标格式
|
||||
if (disableFormatList.includes(cyclicConvertCase.settingsKey)) {
|
||||
if (enabledFormats[cyclicConvertCase.settingsKey] === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -112,4 +112,4 @@ function replaceTextEditorSelectedText() {
|
||||
});
|
||||
userSelection.lastConvertedSelectionsText = textList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -278,114 +278,142 @@ const keyword = {
|
||||
],
|
||||
};
|
||||
|
||||
interface Command {
|
||||
command: string;
|
||||
targetCase: SupportVariableCase;
|
||||
settingsKey: string;
|
||||
// variable-conversion.enabledFormats 中的配置项
|
||||
enableSettingsKey: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接管的变量转换命令
|
||||
*/
|
||||
export const commands: Array<{ command: string; targetCase: SupportVariableCase; settingsKey: string }> = [
|
||||
export const commands: Array<Command> = [
|
||||
{
|
||||
command: 'variable-conversion.toCamelCase',
|
||||
targetCase: SupportVariableCase.CAMEL_CASE,
|
||||
settingsKey: 'camel_case'
|
||||
settingsKey: 'camel_case',
|
||||
enableSettingsKey: 'camelCase.enabled',
|
||||
},
|
||||
{
|
||||
command: 'variable-conversion.toPascalCase',
|
||||
targetCase: SupportVariableCase.PASCAL_CASE,
|
||||
settingsKey: 'pascal_case'
|
||||
settingsKey: 'pascal_case',
|
||||
enableSettingsKey: 'pascalCase.enabled',
|
||||
},
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++
|
||||
{
|
||||
command: 'variable-conversion.toSnakeCase',
|
||||
targetCase: SupportVariableCase.SNAKE_CASE,
|
||||
settingsKey: 'snake_case'
|
||||
settingsKey: 'snake_case',
|
||||
enableSettingsKey: 'snakeCase.enabled',
|
||||
},
|
||||
{
|
||||
command: 'variable-conversion.toSnakeUpperCase',
|
||||
targetCase: SupportVariableCase.SNAKE_UPPER_CASE,
|
||||
settingsKey: 'snake_upper_case'
|
||||
settingsKey: 'snake_upper_case',
|
||||
enableSettingsKey: 'snakeUpperCase.enabled',
|
||||
},
|
||||
{
|
||||
command: 'variable-conversion.toSnakePascalCase',
|
||||
targetCase: SupportVariableCase.SNAKE_PASCAL_CASE,
|
||||
settingsKey: 'snake_pascal_case'
|
||||
settingsKey: 'snake_pascal_case',
|
||||
enableSettingsKey: 'snakePascalCase.enabled',
|
||||
},
|
||||
{
|
||||
command: 'variable-conversion.toSnakeCamelCase',
|
||||
targetCase: SupportVariableCase.SNAKE_CAMEL_CASE,
|
||||
settingsKey: 'snake_camel_case'
|
||||
settingsKey: 'snake_camel_case',
|
||||
enableSettingsKey: 'snakeCamelCase.enabled',
|
||||
},
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++
|
||||
{
|
||||
command: 'variable-conversion.toKebabCase',
|
||||
targetCase: SupportVariableCase.KEBAB_CASE,
|
||||
settingsKey: 'kebab_case'
|
||||
settingsKey: 'kebab_case',
|
||||
enableSettingsKey: 'kebabCase.enabled',
|
||||
},
|
||||
{
|
||||
command: 'variable-conversion.toKebabUpperCase',
|
||||
targetCase: SupportVariableCase.KEBAB_UPPER_CASE,
|
||||
settingsKey: 'kebab_upper_case'
|
||||
settingsKey: 'kebab_upper_case',
|
||||
enableSettingsKey: 'kebabUpperCase.enabled',
|
||||
},
|
||||
{
|
||||
command: 'variable-conversion.toKebabPascalCase',
|
||||
targetCase: SupportVariableCase.KEBAB_PASCAL_CASE,
|
||||
settingsKey: 'kebab_pascal_case'
|
||||
settingsKey: 'kebab_pascal_case',
|
||||
enableSettingsKey: 'kebabPascalCase.enabled',
|
||||
},
|
||||
{
|
||||
command: 'variable-conversion.toKebabCamelCase',
|
||||
targetCase: SupportVariableCase.KEBAB_CAMEL_CASE,
|
||||
settingsKey: 'kebab_camel_case'
|
||||
settingsKey: 'kebab_camel_case',
|
||||
enableSettingsKey: 'kebabCamelCase.enabled',
|
||||
},
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++
|
||||
{
|
||||
command: 'variable-conversion.toSpaceCase',
|
||||
targetCase: SupportVariableCase.SPACE_CASE,
|
||||
settingsKey: 'space_case'
|
||||
settingsKey: 'space_case',
|
||||
enableSettingsKey: 'spaceCase.enabled',
|
||||
},
|
||||
{
|
||||
command: 'variable-conversion.toSpaceUpperCase',
|
||||
targetCase: SupportVariableCase.SPACE_UPPER_CASE,
|
||||
settingsKey: 'space_upper_case'
|
||||
settingsKey: 'space_upper_case',
|
||||
enableSettingsKey: 'spaceUpperCase.enabled',
|
||||
},
|
||||
{
|
||||
command: 'variable-conversion.toSpacePascalCase',
|
||||
targetCase: SupportVariableCase.SPACE_PASCAL_CASE,
|
||||
settingsKey: 'space_pascal_case'
|
||||
settingsKey: 'space_pascal_case',
|
||||
enableSettingsKey: 'spacePascalCase.enabled',
|
||||
},
|
||||
{
|
||||
command: 'variable-conversion.toSpaceCamelCase',
|
||||
targetCase: SupportVariableCase.SPACE_CAMEL_CASE,
|
||||
settingsKey: 'space_camel_case'
|
||||
settingsKey: 'space_camel_case',
|
||||
enableSettingsKey: 'spaceCamelCase.enabled',
|
||||
},
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++
|
||||
{
|
||||
command: 'variable-conversion.toDotCase',
|
||||
targetCase: SupportVariableCase.DOT_CASE,
|
||||
settingsKey: 'dot_case'
|
||||
settingsKey: 'dot_case',
|
||||
enableSettingsKey: 'dotCase.enabled',
|
||||
},
|
||||
{
|
||||
command: 'variable-conversion.toDotUpperCase',
|
||||
targetCase: SupportVariableCase.DOT_UPPER_CASE,
|
||||
settingsKey: 'dot_upper_case'
|
||||
settingsKey: 'dot_upper_case',
|
||||
enableSettingsKey: 'dotUpperCase.enabled',
|
||||
},
|
||||
{
|
||||
command: 'variable-conversion.toDotPascalCase',
|
||||
targetCase: SupportVariableCase.DOT_PASCAL_CASE,
|
||||
settingsKey: 'dot_pascal_case'
|
||||
settingsKey: 'dot_pascal_case',
|
||||
enableSettingsKey: 'dotPascalCase.enabled',
|
||||
},
|
||||
{
|
||||
command: 'variable-conversion.toDotCamelCase',
|
||||
targetCase: SupportVariableCase.DOT_CAMEL_CASE,
|
||||
settingsKey: 'dot_camel_case'
|
||||
settingsKey: 'dot_camel_case',
|
||||
enableSettingsKey: 'dotCamelCase.enabled',
|
||||
},
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++
|
||||
{
|
||||
command: 'variable-conversion.toLowerCase',
|
||||
targetCase: SupportVariableCase.LOWER_CASE,
|
||||
settingsKey: 'lower_case'
|
||||
settingsKey: 'lower_case',
|
||||
enableSettingsKey: 'lowerCase.enabled',
|
||||
},
|
||||
{
|
||||
command: 'variable-conversion.toUpperCase',
|
||||
targetCase: SupportVariableCase.UPPER_CASE,
|
||||
settingsKey: 'upper_case'
|
||||
settingsKey: 'upper_case',
|
||||
enableSettingsKey: 'upperCase.enabled',
|
||||
},
|
||||
];
|
||||
|
||||
|
@@ -64,12 +64,12 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
// issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1
|
||||
// 获取用户配置
|
||||
const disableFormatList = getUserConfigurations<Array<string>>('disableFormat') || [];
|
||||
const enabledFormats = getUserConfigurations<Record<string, boolean>>('enabledFormats') || {};
|
||||
const disablePathFormatList = getUserConfigurations<Array<string>>('disablePathFormat') || [];
|
||||
// 更新右键菜单每一项是否展示
|
||||
// 变量转换右键菜单visible 2024.07.29
|
||||
for (const { settingsKey } of variableCommands) {
|
||||
vscode.commands.executeCommand('setContext', '_isHideSubMenuItem_' + settingsKey, disableFormatList.includes(settingsKey));
|
||||
for (const { settingsKey, enableSettingsKey } of variableCommands) {
|
||||
vscode.commands.executeCommand('setContext', '_isHideSubMenuItem_' + settingsKey, enabledFormats[enableSettingsKey] === false);
|
||||
}
|
||||
// 路径转换右键菜单visible 2024.12.14
|
||||
for (const { settingsKey } of pathCommands) {
|
||||
|
@@ -10,7 +10,7 @@ let statusBarItemList: Array<vscode.StatusBarItem> = [];
|
||||
* @since 2024-04-07
|
||||
*/
|
||||
export function createStatusBarItem() {
|
||||
// 变量转换状态栏 2024.04.07
|
||||
// 变量转换状态栏 2024.04.07
|
||||
const createVariableConvertStatusBarItem = () => {
|
||||
const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
|
||||
// Icon Listing docs: https://code.visualstudio.com/api/references/icons-in-labels#icon-listing
|
||||
@@ -20,7 +20,7 @@ export function createStatusBarItem() {
|
||||
// statusBarItem.show();
|
||||
return statusBarItem;
|
||||
};
|
||||
// 路径转换状态栏 2024.12.14
|
||||
// 路径转换状态栏 2024.12.14
|
||||
const createPathConvertStatusBarItem = () => {
|
||||
const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
|
||||
statusBarItem.text = '$(sync-ignored)路径转换'; // italic symbol-null
|
||||
@@ -51,4 +51,4 @@ export function updateStatusBarItemVisable(selectTextLength: number) {
|
||||
statusBarItemList.forEach(statusBarItem => {
|
||||
statusBarItem.hide();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -98,17 +98,17 @@ export function handleQuickPick() {
|
||||
|
||||
// issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1
|
||||
// 获取用户配置
|
||||
const disableFormatList = getUserConfigurations<Array<string>>('disableFormat') || [];
|
||||
const enabledFormats = getUserConfigurations<Record<string, boolean>>('enabledFormats') || {};
|
||||
// 排除禁用的选项
|
||||
const enabledQuickPickSupportCases = [];
|
||||
for (const quickPick of quickPickSupportCases) {
|
||||
if (disableFormatList.includes(quickPick.settingsKey)) {
|
||||
if (enabledFormats[quickPick.settingsKey] === false) {
|
||||
continue;
|
||||
}
|
||||
enabledQuickPickSupportCases.push(quickPick);
|
||||
}
|
||||
if (enabledQuickPickSupportCases.length === 0) {
|
||||
vscode.window.showInformationMessage('所有格式都已被配置为禁用,请修改配置 `variable-conversion.disableFormat` 后重试\nAll formats have been configured to disable. Modify the `variable-conversion.disableFormat` configuration and try again.');
|
||||
vscode.window.showInformationMessage('所有格式都已被配置为禁用,请修改配置 `variable-conversion.enabledFormats` 后重试\nAll formats have been configured to disable. Modify the `variable-conversion.enabledFormats` configuration and try again.');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -41,4 +41,4 @@ export function stringListArrayDuplicateRemoval(stringArr: Array<string[]>): Arr
|
||||
}
|
||||
}
|
||||
return newArr;
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
],
|
||||
"sourceMap": true,
|
||||
"rootDir": "src",
|
||||
"strict": true /* enable all strict type-checking options */
|
||||
"strict": true, /* enable all strict type-checking options */
|
||||
/* Additional Checks */
|
||||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||
|
Reference in New Issue
Block a user