diff --git a/CHANGELOG.md b/CHANGELOG.md index fcd3ddc..8ae6249 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 --> +## 2.0.0 + +### Added + +- New: Support path conversions via shortcut keys `Ctrl + Alt + /` and `Ctrl + Shift + Alt + /` (also supports multi-selection conversion). (支持通过 `Ctrl + Alt + /`, `Ctrl + Shift + Alt + /` 快捷键进行路径转换 (同时支持多选区转换)) +- New: Support following path conversion type: QuickPick menu conversion, context menu conversion, status bar button conversion, shortcut key conversion. (支持以下路径转换方式:QuickPick 菜单转换、右键菜单转换、状态栏按钮转换、快捷键转换) + +### Changed + +- Do not display the editor context menu `Variable Conversion` option when text is not selected. (当未选中文本时,不显示右键菜单 `变量转换` 选项) + +### Improvement + +- Adjust the project code directory structure. (项目代码目录结构调整) + ## 1.1.0 ### Added @@ -46,7 +61,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - New: Supports multi-selection conversion (支持多选区转换) -- New: Supports scrolling conversion via shortcut keys `Ctrl + Alt + [` and `Ctrl + Alt + ]` (also supports multi-selection conversion) 支持通过快捷键循环转换 (同时支持多选区转换) +- New: Supports scrolling variable conversion via shortcut keys `Ctrl + Alt + [` and `Ctrl + Alt + ]` (also supports multi-selection conversion). (支持通过 `Ctrl + Alt + [`, `Ctrl + Alt + ]` 快捷键进行变量循环转换 (同时支持多选区转换)) ## 1.0.7 diff --git a/README.md b/README.md index 63bc720..289f368 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,24 @@ -# 变量命名转换插件 Variable Conversion +# 变量命名转换助手 — Variable Conversion (VSCode 扩展) [Marketplace](https://marketplace.visualstudio.com/items?itemName=coder-xiaomo.variable-conversion) [GitHub](https://github.com/coder-xiaomo/variable-conversion-vscode-extension.git) [Gitee](https://gitee.com/coder-xiaomo/variable-conversion-vscode-extension.git) -一个强大的变量名转换插件,支持一键转换、循环转换,支持右键菜单、快捷键、状态栏等多种方式使用。
-A powerful variable naming conversion extension. Supports one-key conversion & cyclic conversion. You can use it through the editer menu, shortcut keys and bottom bar. +一个强大的变量命名及路径风格转换插件,支持一键转换、循环转换,支持右键菜单、快捷键、状态栏等多种方式使用。
+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) +> +> - 支持 Windows / Unix 路径风格转换(可选中文本中的路径,然后使用 `Ctrl + Alt + /` 快捷键,或点击右键菜单、底部状态栏路径转换按钮轻松实现转换) - ✅ 支持多选区 Support multi-selection -- ✅ 支持多窗口 (不支持子窗口状态栏) Support subwindow (subwindow status bar are not supported) +- ✅ 支持多窗口 Support subwindow - ✅ 支持撤回 & 重做 Support undo & redo (Ctrl + Z / Ctrl + Y) +- ✅ 支持禁用部分目标转换格式 Supports disabling some target conversion formats > 🔭 Tips for Chinese users: 如果您无法看到下文图片,请[点这里](https://gitee.com/coder-xiaomo/variable-conversion-vscode-extension/blob/main/README.md)查看 ## 如何使用? How to Use? -### 循环转换 Cyclic conversion (Beta) +### 循环转换 Cyclic conversion 选中需要转换的内容,然后按下 `Ctrl + Alt + [` 或 `Ctrl + Alt + ]` 即可前后灵活切换变量命名方式。
Select what you want to convert in the editor, and then press `Ctrl + Alt + [` or `Ctrl + Alt + ]` to flexibly convert variable name flexibly. @@ -47,15 +52,37 @@ Or right-click on the selected text -> Convert string to... **3. 选择转换目标,转换完成** **Select the conversion target and complete** +### 路径转换 Path Conversion (Beta) + +> 该功能仍在 Beta 测试阶段,如您在使用过程中遇到问题,欢迎通过文末联系方式进行反馈。 +> +> This feature is still in Beta testing stage, if you encounter any problems during use, please give feedback via the contact information at the end of the article. + +路径转换与变量转换操作逻辑基本相同,都可以通过 *右键菜单*、*底部状态栏*、*快捷键* 等方式使用,唯一区别是快捷键的不同。 + +路径转换快捷键为: + +- 切换下一个路径风格:`Ctrl + Alt + /` +- 切换上一个路径风格:`Ctrl + Alt + Shift + /` + +![Path Conversion](image/path-conversion.gif) + +**注:**目前 `v2.0.0` 版本暂仅支持 `Windows 风格路径` 与 `Unix 风格路径` 互转,所以这两个快捷键目前效果相同。**后续会陆续增加其他更多路径风格**(例如 `Windows Git Bash` 风格,浏览器 `file://` 协议风格等),敬请期待。 + ## 快捷键 Shortcut key -| 功能 Feature | 快捷键 shortcut key | -| ------------------------------------------------ | ------------------- | -| 变量转换 快速选择 QuickPick | Shift + Alt + T | -| 循环转换→上一个 Cyclic conversion → Previous one | Ctrl + Alt + [ | -| 循环转换→下一个 Cyclic conversion → Next one | Ctrl + Alt + ] | +| 功能 Feature | 快捷键 shortcut key | +| ------------------------------------------------------------ | ---------------------- | +| 变量转换 快速选择 Variable Conversion QuickPick | Shift + Alt + T | +| 变量循环转换→上一个 Variable Cyclic Conversion → Previous one | Ctrl + Alt + [ | +| 变量循环转换→下一个 Variable Cyclic Conversion → Next one | Ctrl + Alt + ] | +| 路径转换 快速选择 Path Conversion QuickPick | Shift + Alt + / | +| 路径循环转换→上一个 Path Cyclic conversion → Previous one | Ctrl + Alt + / | +| 路径循环转换→下一个 Path Cyclic conversion → Next one | Ctrl + Shift + Alt + / | -## 配置项 configurations +> 若您觉得快捷键使用不顺手,您可在 VSCode 左下角齿轮图标⚙ → 键盘快捷方式中自定义修改快捷键。 + +## 配置项 Configurations | 配置项 Configuration Key | 描述 Description | 配置示例 | 默认值 | | ----------------------------------- | ------------------------------------------------------------ | ------------------------------ | ------ | @@ -63,6 +90,8 @@ Or right-click on the selected text -> Convert string to... ## 支持的类型 Support Case +### 变量转换 + | 类型 | Case | 举例 e.g. | | ------------------------------------------ | ------------------------ | ---------------- | | 小驼峰(驼峰)命名 | Camel Case | fooBar | @@ -86,6 +115,26 @@ Or right-click on the selected text -> Convert string to... | 全小写 | Lower Case | foo_bar / foobar | | 全大写 | Upper Case | FOO_BAR / FOOBAR | +### 路径转换 + +现已支持的路径风格: + +| 路径风格 | Sttyle | 举例 e.g. | +| ------------ | ------------- | ---------------------------------------------- | +| Windows 风格 | Windows Style | `C:\Windows\System32`
`.\public\assets\` | +| Unix 风格 | Unix Style | `/usr/bin`
`./public/assets/` | + +尚未支持的路径风格: + +| 路径风格 | Case | 举例 e.g. | +| -------------------------- | --------------------------------- | ------------------------------------- | +| 👇未来计划支持 | | | +| Windows 风格(反斜杠转义) | Windows Style (Backslash Escaped) | `C:\\Windows\\System32` | +| Unix 风格(反斜杠转义) | Unix Style (Backslash Escaped) | `\/usr\/bin` | +| Windows Git Bash 风格 | Windows Git Bash Style | `/c/Windows/System32` | +| 👇未来可能支持 | | | +| 浏览器 `file://` 协议风格 | | `file:///C:/Program%20Files%20(x86)/` | + ## 小提示 Tips #### 关于文本选区... About text selections... diff --git a/image/path-conversion.gif b/image/path-conversion.gif new file mode 100644 index 0000000..e32532e Binary files /dev/null and b/image/path-conversion.gif differ diff --git a/package-lock.json b/package-lock.json index 70dc77c..76a2255 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "variable-conversion", - "version": "1.1.0", + "version": "2.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "variable-conversion", - "version": "1.1.0", + "version": "2.0.0", "devDependencies": { "@types/mocha": "^10.0.6", "@types/node": "18.x", diff --git a/package.json b/package.json index 83e5560..05b7f4a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "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": "1.1.0", + "version": "2.0.0", "icon": "image/logo.png", "publisher": "coder-xiaomo", "engines": { @@ -52,6 +52,27 @@ "arrowKey": "]" }, "when": "editorTextFocus" + }, + { + "command": "variable-conversion.convertPath", + "key": "shift+alt+/", + "when": "editorTextFocus" + }, + { + "command": "variable-conversion.cyclicConvertPath.previous", + "key": "ctrl+alt+shift+/", + "args": { + "direction": "<-" + }, + "when": "editorTextFocus" + }, + { + "command": "variable-conversion.cyclicConvertPath.next", + "key": "ctrl+alt+/", + "args": { + "direction": "->" + }, + "when": "editorTextFocus" } ], "commands": [ @@ -138,19 +159,41 @@ { "command": "variable-conversion.toUpperCase", "title": "全大写 (Upper Case) [ FOOBAR ]" + }, + { + "command": "variable-conversion.convertPath", + "title": "路径转换" + }, + { + "command": "variable-conversion.pathFormat.toWindowsStyle", + "title": "Windows 风格 [ C:\\Windows\\System32 ]" + }, + { + "command": "variable-conversion.pathFormat.toUnixStyle", + "title": "Unix 风格 [ /usr/bin ]" } ], "menus": { "editor/context": [ { - "when": "editorTextFocus", + "when": "editorTextFocus && _textSelectionLength >= 1", "command": "variable-conversion.convertCase", - "group": "navigation@9" + "group": "navigation@10" }, { "when": "editorTextFocus && _textSelectionLength >= 1", "submenu": "variable-conversion.stringConversionMenu", - "group": "navigation@9" + "group": "navigation@11" + }, + { + "when": "editorTextFocus && _textSelectionLength >= 1", + "command": "variable-conversion.convertPath", + "group": "navigation@12" + }, + { + "when": "editorTextFocus && _textSelectionLength >= 1", + "submenu": "variable-conversion.pathConversionMenu", + "group": "navigation@13" } ], "variable-conversion.stringConversionMenu": [ @@ -254,12 +297,28 @@ "command": "variable-conversion.toUpperCase", "group": "group-6-upper-lower@2" } + ], + "variable-conversion.pathConversionMenu": [ + { + "when": "!_isHideSubMenuItem_windows_style", + "command": "variable-conversion.pathFormat.toWindowsStyle", + "group": "group-1-common-style@1" + }, + { + "when": "!_isHideSubMenuItem_unix_style", + "command": "variable-conversion.pathFormat.toUnixStyle", + "group": "group-1-common-style@2" + } ] }, "submenus": [ { "id": "variable-conversion.stringConversionMenu", "label": "将变量转换为..." + }, + { + "id": "variable-conversion.pathConversionMenu", + "label": "将路径转换为..." } ], "configuration": { @@ -267,7 +326,7 @@ "properties": { "variable-conversion.disableFormat": { "order": 1, - "markdownDescription": "定义哪些格式是禁用的\n\nDefine which 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)", + "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)", "type": "array", "items": { "type": "string", @@ -317,6 +376,23 @@ ] }, "default": [] + }, + "variable-conversion.disablePathFormat": { + "order": 3, + "markdownDescription": "定义哪些路径风格是禁用的\n\nDefine which path 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.disablePathFormat\": [ ... ],`\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)", + "type": "array", + "items": { + "type": "string", + "enum": [ + "windows_style", + "unix_style" + ], + "enumDescriptions": [ + "Windows 风格", + "Unix 风格" + ] + }, + "default": [] } } } diff --git a/src/core/path-convert/conversion.ts b/src/core/path-convert/conversion.ts new file mode 100644 index 0000000..659178f --- /dev/null +++ b/src/core/path-convert/conversion.ts @@ -0,0 +1,62 @@ +import { EOL } from "../../types/EOLType"; +import { SupportPathFormat } from "./types/SupportPathFormatType"; +import { TransformTextResult } from '../../types/TransformTextResultType'; + +/** / */ +const LEFT_SLASH = '/'; +/** \ */ +const RIGHT_SLASH = '\\'; +/** \\ */ +const DOUBLE_RIGHT_SLASH = '\\\\'; + +export function pathConversion(targetPathType: SupportPathFormat, input: string, eol: EOL, cutText: Array | undefined = undefined): string { + let resultPath; + + let isSeperator = false; + switch (targetPathType) { + case SupportPathFormat.Windows: + // 将其中的 / 替换为 \ + resultPath = Array.from(input).map((char: string) => { + if (char !== LEFT_SLASH) { + // 当前字符不是 / + isSeperator = false; + return char; + } else { + // 当前字符是 / + if (!isSeperator) { + // 上一字符不是 / + isSeperator = true; + return RIGHT_SLASH; // 替换成 \ + } + // 上一字符是 / + return ''; + } + }).join(''); + break; + case SupportPathFormat.Unix: + // 将其中的 \\ 和 \ 替换为 / + resultPath = Array.from(input).map((char: string) => { + if (char !== RIGHT_SLASH) { + // 当前字符不是 \ + isSeperator = false; + return char; + } else { + // 当前字符是 \ + if (!isSeperator) { + // 上一字符不是 \ + isSeperator = true; + return LEFT_SLASH; // 替换成 / + } + // 上一字符是 \ + return ''; + } + }).join(''); + break; + // case SupportPathFormat.WindowsGitBash: + // break; + default: + return input; + } + + return resultPath; +} diff --git a/src/core/path-convert/cyclic-conversion.ts b/src/core/path-convert/cyclic-conversion.ts new file mode 100644 index 0000000..12e8b5a --- /dev/null +++ b/src/core/path-convert/cyclic-conversion.ts @@ -0,0 +1,116 @@ +import * as vscode from 'vscode'; +import { EOL } from "../../types/EOLType"; +import { cyclicConvertPathOrder } from "./types/SupportPathFormatType"; +import { pathConversion } from "./conversion"; +import { isStringArrayEqual, stringListArrayDuplicateRemoval } from '../../utils/utils'; +import { getUserConfigurations } from '../../utils/user-configuration'; + +interface UserSelection { + currentEol: EOL + currentSelections?: readonly vscode.Selection[] + currentSelectionsText: string[] + currentIndex: number + isConverted: boolean + conversionsTarget: Array + lastConvertedSelectionsText: string[] // 按快捷键后转换的值(如果下次触发 onUserSelectionUpdated 后传入值是这个,那么跳过,避免丢失当前循环转换记录) +} + +const userSelection: UserSelection = { + currentEol: '\n', + // currentSelections: undefined, + currentSelectionsText: [], + currentIndex: 0, + isConverted: false, + conversionsTarget: [], // 转换后去重 剩余转换目标 + lastConvertedSelectionsText: [], +}; + +export function onUserSelectionUpdated(selections: readonly vscode.Selection[], textList: string[], eol: EOL): void { + userSelection.currentSelections = selections; + if (textList.length !== 0 && isStringArrayEqual(textList, userSelection.lastConvertedSelectionsText)) { + // console.log('skip onUserSelectionUpdated'); + return; + } + // console.log('onUserSelectionUpdated', textList, userSelection.lastConvertedSelectionsText); + userSelection.currentEol = eol; + userSelection.currentSelectionsText = textList; + userSelection.currentIndex = 0; + userSelection.isConverted = false; + userSelection.conversionsTarget = [textList]; + userSelection.lastConvertedSelectionsText = textList; +} + +export function previousOne() { + lazyConvert(); + const length = userSelection.conversionsTarget.length; + const oldIndex = userSelection.currentIndex; + const newIndex = oldIndex === 0 ? (length - 1) : (oldIndex - 1); + userSelection.currentIndex = newIndex; + console.log('previousOne oldIndex', oldIndex, 'newIndex', newIndex); + replaceTextEditorSelectedText(); +} + +export function nextOne() { + lazyConvert(); + const length = userSelection.conversionsTarget.length; + const oldIndex = userSelection.currentIndex; + const newIndex = oldIndex >= length - 1 ? 0 : (oldIndex + 1); + userSelection.currentIndex = newIndex; + console.log('nextOne oldIndex', oldIndex, 'newIndex', newIndex); + replaceTextEditorSelectedText(); +} + +function lazyConvert() { + if (userSelection.isConverted) { + return; + } + + // 获取用户配置 + // TODO + // const disablePathFormatList = getUserConfigurations>('disablePathFormat') || []; + + const textList = userSelection.currentSelectionsText; + // vscode.window.showInformationMessage('lazyConvert' + textList.join('\n')); + const eol = userSelection.currentEol; + const conversionsTarget: Array = [textList]; + for (const cyclicConvertCase of cyclicConvertPathOrder) { + // 跳过禁用的目标格式 + // TODO + // if (disablePathFormatList.includes(cyclicConvertCase.settingsKey)) { + // continue; + // } + + // 每一个类型 + const conversionsTargetItem: string[] = []; + for (const line of textList) { + // 选中区块的每一行 + const conversionResult: string = pathConversion(cyclicConvertCase.type, line, eol); + conversionsTargetItem.push(conversionResult); + } + conversionsTarget.push(conversionsTargetItem); + } + + // 按数组去重 + const noDuplicate = stringListArrayDuplicateRemoval(conversionsTarget); + // console.log('noDuplicate', noDuplicate); + + userSelection.conversionsTarget = noDuplicate; + userSelection.isConverted = true; +} + +function replaceTextEditorSelectedText() { + let editor = vscode.window.activeTextEditor; + if (editor) { + const selections = userSelection.currentSelections || []; + const textList = userSelection.conversionsTarget[userSelection.currentIndex]; + console.log('selections', selections, 'textList', textList); + editor.edit(editBuilder => { + for (let i = 0; i < selections.length; i++) { + const selection = selections[i]; + const converted = textList[i]; + editBuilder.replace(selection, converted); + } + }); + userSelection.lastConvertedSelectionsText = textList; + } +} \ No newline at end of file diff --git a/src/core/path-convert/types/SupportPathFormatType.ts b/src/core/path-convert/types/SupportPathFormatType.ts new file mode 100644 index 0000000..1a96800 --- /dev/null +++ b/src/core/path-convert/types/SupportPathFormatType.ts @@ -0,0 +1,101 @@ +/** + * 路径转换类型 + * + * @since 2024-12-14 + */ +export enum SupportPathFormat { + + /** + * Windows 风格 + * + * @alias: windows / Windows + * @since 2024-12-07 + */ + Windows, + + /** + * Unix 风格 + * + * @alias: unix / Unix + * @since 2024-12-07 + */ + Unix, +}; + +const keyword = { + windows: [ + 'Windows', 'win', + ], + unix: [ + 'Unix', + 'Linux', + 'macOS', + ], +}; + +/** + * 接管的变量转换命令 + * + * @since 2024-12-14 + */ +export const commands: Array<{ command: string; targetCase: SupportPathFormat; settingsKey: string }> = [ + { + command: 'variable-conversion.pathFormat.toWindowsStyle', + targetCase: SupportPathFormat.Windows, + settingsKey: 'windows_style' + }, + { + command: 'variable-conversion.pathFormat.toUnixStyle', + targetCase: SupportPathFormat.Unix, + settingsKey: 'unix_style' + }, +]; + +/** + * @since 2024-12-14 + */ +export interface QuickPickSupportCaseItem { + type: SupportPathFormat, + name: string, + shortName: string, + keyword: string[], + settingsKey: string, +} + +/** + * 所有支持的路径风格 + * @since 2024-12-14 + */ +export const quickPickSupportCases: Array = [ + { + type: SupportPathFormat.Windows, + name: 'Microsoft Windows 风格', + shortName: 'Windows 风格', + keyword: keyword.windows, + settingsKey: 'windows_style', + }, + { + type: SupportPathFormat.Unix, + name: 'Unix / 类 Unix 风格 (Linux, macOS, ...)', + shortName: 'Unix 风格', + keyword: keyword.unix, + settingsKey: 'unix_style', + }, +]; + +/** + * @since 2024-12-14 + */ +export interface CyclicConvertPathOrderItem { + type: SupportPathFormat, + settingsKey: string, +} + +/** + * 通过快捷键循环转换的顺序 + * @since 2024-12-14 + */ +export const cyclicConvertPathOrder: Array = [ + { type: SupportPathFormat.Windows, settingsKey: 'windows' }, + { type: SupportPathFormat.Unix, settingsKey: 'unix' }, +]; diff --git a/src/main-code/conversion.ts b/src/core/variable-convert/conversion.ts similarity index 51% rename from src/main-code/conversion.ts rename to src/core/variable-convert/conversion.ts index 789bbcc..b0ac686 100644 --- a/src/main-code/conversion.ts +++ b/src/core/variable-convert/conversion.ts @@ -1,52 +1,53 @@ -import { EOL } from '../type-definition/EOLType'; -import { SupportCase } from '../type-definition/SupportCaseType'; -import { TransformTextResult } from '../type-definition/TransformTextResultType'; -import { transformMutliLineText, transformText } from './transform'; +import { EOL } from '../../types/EOLType'; +import { SupportVariableCase } from './types/SupportVariableCaseType'; +import { TransformTextResult } from '../../types/TransformTextResultType'; +import { transformMutliLineText, transformText } from '../../utils/transform'; /** * 统一文本转换函数 * - * @param {SupportCase} targetCase 目标文本情况 + * @param {SupportVariableCase} targetCase 目标文本情况 * @param {string} str 用户选择的文本 user selection * @param {EOL} eol 行结束符 + * @param {Array?} cutText 行结束符 * @returns 转换后的文本 * @since 2024-04-04 */ -export function caseConversion(targetCase: SupportCase, str: string, eol: EOL, cutText: Array | undefined = undefined): string { +export function caseConversion(targetCase: SupportVariableCase, str: string, eol: EOL, cutText: Array | undefined = undefined): string { let spaceCharacter: '-' | '_' | ' ' | '.' | undefined = undefined; switch (targetCase) { default: - case SupportCase.CAMEL_CASE: // 小驼峰(驼峰)命名 - case SupportCase.PASCAL_CASE: // 大驼峰(帕斯卡)命名 + case SupportVariableCase.CAMEL_CASE: // 小驼峰(驼峰)命名 + case SupportVariableCase.PASCAL_CASE: // 大驼峰(帕斯卡)命名 spaceCharacter = undefined; break; - case SupportCase.SNAKE_CASE: // 下划线(蛇形)命名 - case SupportCase.SNAKE_CAMEL_CASE: // 下划线(蛇形) + 小驼峰(驼峰)命名 - case SupportCase.SNAKE_PASCAL_CASE: // 下划线(蛇形) + 大驼峰(帕斯卡)命名 - case SupportCase.SNAKE_UPPER_CASE: // 下划线(蛇形) + 全大写命名 + case SupportVariableCase.SNAKE_CASE: // 下划线(蛇形)命名 + case SupportVariableCase.SNAKE_CAMEL_CASE: // 下划线(蛇形) + 小驼峰(驼峰)命名 + case SupportVariableCase.SNAKE_PASCAL_CASE: // 下划线(蛇形) + 大驼峰(帕斯卡)命名 + case SupportVariableCase.SNAKE_UPPER_CASE: // 下划线(蛇形) + 全大写命名 spaceCharacter = '_'; break; - case SupportCase.KEBAB_CASE: // 中划线(连字符/脊柱式)命名 - case SupportCase.KEBAB_CAMEL_CASE: // 中划线(连字符/脊柱式) + 小驼峰(驼峰)命名 - case SupportCase.KEBAB_PASCAL_CASE: // 中划线(连字符/脊柱式) + 大驼峰(帕斯卡)命名 - case SupportCase.KEBAB_UPPER_CASE: // 中划线(连字符/脊柱式) + 全大写命名 + case SupportVariableCase.KEBAB_CASE: // 中划线(连字符/脊柱式)命名 + case SupportVariableCase.KEBAB_CAMEL_CASE: // 中划线(连字符/脊柱式) + 小驼峰(驼峰)命名 + case SupportVariableCase.KEBAB_PASCAL_CASE: // 中划线(连字符/脊柱式) + 大驼峰(帕斯卡)命名 + case SupportVariableCase.KEBAB_UPPER_CASE: // 中划线(连字符/脊柱式) + 全大写命名 spaceCharacter = '-'; break; - case SupportCase.SPACE_CASE: // 空格分隔命名 - case SupportCase.SPACE_CAMEL_CASE: // 空格分隔 + 小驼峰(驼峰)命名 - case SupportCase.SPACE_PASCAL_CASE: // 空格分隔 + 大驼峰(帕斯卡)命名 - case SupportCase.SPACE_UPPER_CASE: // 空格分隔 + 全大写命名 + case SupportVariableCase.SPACE_CASE: // 空格分隔命名 + case SupportVariableCase.SPACE_CAMEL_CASE: // 空格分隔 + 小驼峰(驼峰)命名 + case SupportVariableCase.SPACE_PASCAL_CASE: // 空格分隔 + 大驼峰(帕斯卡)命名 + case SupportVariableCase.SPACE_UPPER_CASE: // 空格分隔 + 全大写命名 spaceCharacter = ' '; break; - case SupportCase.DOT_CASE: // 点分隔命名 - case SupportCase.DOT_CAMEL_CASE: // 点分隔 + 小驼峰(驼峰)命名 - case SupportCase.DOT_PASCAL_CASE: // 点分隔 + 大驼峰(帕斯卡)命名 - case SupportCase.DOT_UPPER_CASE: // 点分隔 + 全大写命名 + case SupportVariableCase.DOT_CASE: // 点分隔命名 + case SupportVariableCase.DOT_CAMEL_CASE: // 点分隔 + 小驼峰(驼峰)命名 + case SupportVariableCase.DOT_PASCAL_CASE: // 点分隔 + 大驼峰(帕斯卡)命名 + case SupportVariableCase.DOT_UPPER_CASE: // 点分隔 + 全大写命名 spaceCharacter = '.'; break; - case SupportCase.LOWER_CASE: // 全小写 + case SupportVariableCase.LOWER_CASE: // 全小写 return str.toLowerCase(); - case SupportCase.UPPER_CASE: // 全大写 + case SupportVariableCase.UPPER_CASE: // 全大写 return str.toUpperCase(); } @@ -84,11 +85,11 @@ export function caseConversion(targetCase: SupportCase, str: string, eol: EOL, c // 根据目标情况转换单词 switch (targetCase) { - case SupportCase.CAMEL_CASE: // 小驼峰(驼峰)命名 - case SupportCase.SNAKE_CAMEL_CASE: // 下划线(蛇形) + 小驼峰(驼峰)命名 - case SupportCase.KEBAB_CAMEL_CASE: // 中划线(连字符/脊柱式) + 小驼峰(驼峰)命名 - case SupportCase.SPACE_CAMEL_CASE: // 空格分隔 + 小驼峰(驼峰)命名 - case SupportCase.DOT_CAMEL_CASE: // 点分隔 + 小驼峰(驼峰)命名 + case SupportVariableCase.CAMEL_CASE: // 小驼峰(驼峰)命名 + case SupportVariableCase.SNAKE_CAMEL_CASE: // 下划线(蛇形) + 小驼峰(驼峰)命名 + case SupportVariableCase.KEBAB_CAMEL_CASE: // 中划线(连字符/脊柱式) + 小驼峰(驼峰)命名 + case SupportVariableCase.SPACE_CAMEL_CASE: // 空格分隔 + 小驼峰(驼峰)命名 + case SupportVariableCase.DOT_CAMEL_CASE: // 点分隔 + 小驼峰(驼峰)命名 if (isFirstWord) { transformedWords.push(word); if (isCurrentWordNormal) { @@ -98,23 +99,23 @@ export function caseConversion(targetCase: SupportCase, str: string, eol: EOL, c transformedWords.push(pascalCaseWord); } break; - case SupportCase.PASCAL_CASE: // 大驼峰(帕斯卡)命名 - case SupportCase.SNAKE_PASCAL_CASE: // 下划线(蛇形) + 大驼峰(帕斯卡)命名 - case SupportCase.KEBAB_PASCAL_CASE: // 中划线(连字符/脊柱式) + 大驼峰(帕斯卡)命名 - case SupportCase.SPACE_PASCAL_CASE: // 空格分隔 + 大驼峰(帕斯卡)命名 - case SupportCase.DOT_PASCAL_CASE: // 点分隔 + 大驼峰(帕斯卡)命名 + case SupportVariableCase.PASCAL_CASE: // 大驼峰(帕斯卡)命名 + case SupportVariableCase.SNAKE_PASCAL_CASE: // 下划线(蛇形) + 大驼峰(帕斯卡)命名 + case SupportVariableCase.KEBAB_PASCAL_CASE: // 中划线(连字符/脊柱式) + 大驼峰(帕斯卡)命名 + case SupportVariableCase.SPACE_PASCAL_CASE: // 空格分隔 + 大驼峰(帕斯卡)命名 + case SupportVariableCase.DOT_PASCAL_CASE: // 点分隔 + 大驼峰(帕斯卡)命名 transformedWords.push(pascalCaseWord); break; - case SupportCase.SNAKE_CASE: // 下划线(蛇形)命名 - case SupportCase.KEBAB_CASE: // 中划线(连字符/脊柱式)命名 - case SupportCase.SPACE_CASE: // 空格分隔命名 - case SupportCase.DOT_CASE: // 点分隔命名x + case SupportVariableCase.SNAKE_CASE: // 下划线(蛇形)命名 + case SupportVariableCase.KEBAB_CASE: // 中划线(连字符/脊柱式)命名 + case SupportVariableCase.SPACE_CASE: // 空格分隔命名 + case SupportVariableCase.DOT_CASE: // 点分隔命名 transformedWords.push(word); break; - case SupportCase.SNAKE_UPPER_CASE: // 下划线(蛇形) + 全大写命名 - case SupportCase.KEBAB_UPPER_CASE: // 中划线(连字符/脊柱式) + 全大写命名 - case SupportCase.SPACE_UPPER_CASE: // 空格分隔 + 全大写命名 - case SupportCase.DOT_UPPER_CASE: // 点分隔 + 全大写命名 + case SupportVariableCase.SNAKE_UPPER_CASE: // 下划线(蛇形) + 全大写命名 + case SupportVariableCase.KEBAB_UPPER_CASE: // 中划线(连字符/脊柱式) + 全大写命名 + case SupportVariableCase.SPACE_UPPER_CASE: // 空格分隔 + 全大写命名 + case SupportVariableCase.DOT_UPPER_CASE: // 点分隔 + 全大写命名 transformedWords.push(word.toUpperCase()); break; default: diff --git a/src/main-code/cyclic-conversion.ts b/src/core/variable-convert/cyclic-conversion.ts similarity index 93% rename from src/main-code/cyclic-conversion.ts rename to src/core/variable-convert/cyclic-conversion.ts index 99fa4d9..25e2532 100644 --- a/src/main-code/cyclic-conversion.ts +++ b/src/core/variable-convert/cyclic-conversion.ts @@ -1,9 +1,9 @@ import * as vscode from 'vscode'; -import { EOL } from "../type-definition/EOLType"; -import { cyclicConvertCaseOrder } from "../type-definition/SupportCaseType"; +import { EOL } from "../../types/EOLType"; +import { cyclicConvertCaseOrder } from "./types/SupportVariableCaseType"; import { caseConversion } from "./conversion"; -import { isStringArrayEqual, stringListArrayDuplicateRemoval } from './utils'; -import { getUserConfigurations } from './user-configuration'; +import { isStringArrayEqual, stringListArrayDuplicateRemoval } from '../../utils/utils'; +import { getUserConfigurations } from '../../utils/user-configuration'; interface UserSelection { currentEol: EOL @@ -66,7 +66,7 @@ function lazyConvert() { } // 获取用户配置 - const disableFormatList = getUserConfigurations('disableFormat'); + const disableFormatList = getUserConfigurations>('disableFormat') || []; const textList = userSelection.currentSelectionsText; // vscode.window.showInformationMessage('lazyConvert' + textList.join('\n')); diff --git a/src/type-definition/SupportCaseType.ts b/src/core/variable-convert/types/SupportVariableCaseType.ts similarity index 76% rename from src/type-definition/SupportCaseType.ts rename to src/core/variable-convert/types/SupportVariableCaseType.ts index 453e6e0..fc6d173 100644 --- a/src/type-definition/SupportCaseType.ts +++ b/src/core/variable-convert/types/SupportVariableCaseType.ts @@ -1,13 +1,13 @@ /** - * When support a new case, there's something we need to do. + * When support a new variable case, there's something we need to do. * * Code: * - Add type definition in below `SupportCase` enum and following array * - Add `commands`, `menus`, `configuration` parts in [package.json] and [package-comment.jsonc] - * - Add main conversion logic in [src/main-code/conversion.ts] + * - Add main conversion logic in [src/core/variable-convert/conversion.ts] * * Test: - * - Add test case type definition in [src/type-definition/TestCaseType.ts] + * - Add test case type definition in [src/test/types/TestCaseType.ts] * - Add test case in [src/test/test-case.ts] * - Add test code in [src/test/extension.test.ts] * @@ -15,7 +15,7 @@ * - Modify `description` in [package.json] and [package-comment.jsonc] * - Add changes in [CHANGELOG.md] and [README.md] */ -export enum SupportCase { +export enum SupportVariableCase { /** * 小驼峰(驼峰)命名 @@ -281,116 +281,116 @@ const keyword = { /** * 接管的变量转换命令 */ -export const commands: Array<{ command: string; targetCase: SupportCase; settingsKey: string }> = [ +export const commands: Array<{ command: string; targetCase: SupportVariableCase; settingsKey: string }> = [ { command: 'variable-conversion.toCamelCase', - targetCase: SupportCase.CAMEL_CASE, + targetCase: SupportVariableCase.CAMEL_CASE, settingsKey: 'camel_case' }, { command: 'variable-conversion.toPascalCase', - targetCase: SupportCase.PASCAL_CASE, + targetCase: SupportVariableCase.PASCAL_CASE, settingsKey: 'pascal_case' }, // +++++++++++++++++++++++++++++++++++++++++++++++ { command: 'variable-conversion.toSnakeCase', - targetCase: SupportCase.SNAKE_CASE, + targetCase: SupportVariableCase.SNAKE_CASE, settingsKey: 'snake_case' }, { command: 'variable-conversion.toSnakeUpperCase', - targetCase: SupportCase.SNAKE_UPPER_CASE, + targetCase: SupportVariableCase.SNAKE_UPPER_CASE, settingsKey: 'snake_upper_case' }, { command: 'variable-conversion.toSnakePascalCase', - targetCase: SupportCase.SNAKE_PASCAL_CASE, + targetCase: SupportVariableCase.SNAKE_PASCAL_CASE, settingsKey: 'snake_pascal_case' }, { command: 'variable-conversion.toSnakeCamelCase', - targetCase: SupportCase.SNAKE_CAMEL_CASE, + targetCase: SupportVariableCase.SNAKE_CAMEL_CASE, settingsKey: 'snake_camel_case' }, // +++++++++++++++++++++++++++++++++++++++++++++++ { command: 'variable-conversion.toKebabCase', - targetCase: SupportCase.KEBAB_CASE, + targetCase: SupportVariableCase.KEBAB_CASE, settingsKey: 'kebab_case' }, { command: 'variable-conversion.toKebabUpperCase', - targetCase: SupportCase.KEBAB_UPPER_CASE, + targetCase: SupportVariableCase.KEBAB_UPPER_CASE, settingsKey: 'kebab_upper_case' }, { command: 'variable-conversion.toKebabPascalCase', - targetCase: SupportCase.KEBAB_PASCAL_CASE, + targetCase: SupportVariableCase.KEBAB_PASCAL_CASE, settingsKey: 'kebab_pascal_case' }, { command: 'variable-conversion.toKebabCamelCase', - targetCase: SupportCase.KEBAB_CAMEL_CASE, + targetCase: SupportVariableCase.KEBAB_CAMEL_CASE, settingsKey: 'kebab_camel_case' }, // +++++++++++++++++++++++++++++++++++++++++++++++ { command: 'variable-conversion.toSpaceCase', - targetCase: SupportCase.SPACE_CASE, + targetCase: SupportVariableCase.SPACE_CASE, settingsKey: 'space_case' }, { command: 'variable-conversion.toSpaceUpperCase', - targetCase: SupportCase.SPACE_UPPER_CASE, + targetCase: SupportVariableCase.SPACE_UPPER_CASE, settingsKey: 'space_upper_case' }, { command: 'variable-conversion.toSpacePascalCase', - targetCase: SupportCase.SPACE_PASCAL_CASE, + targetCase: SupportVariableCase.SPACE_PASCAL_CASE, settingsKey: 'space_pascal_case' }, { command: 'variable-conversion.toSpaceCamelCase', - targetCase: SupportCase.SPACE_CAMEL_CASE, + targetCase: SupportVariableCase.SPACE_CAMEL_CASE, settingsKey: 'space_camel_case' }, // +++++++++++++++++++++++++++++++++++++++++++++++ { command: 'variable-conversion.toDotCase', - targetCase: SupportCase.DOT_CASE, + targetCase: SupportVariableCase.DOT_CASE, settingsKey: 'dot_case' }, { command: 'variable-conversion.toDotUpperCase', - targetCase: SupportCase.DOT_UPPER_CASE, + targetCase: SupportVariableCase.DOT_UPPER_CASE, settingsKey: 'dot_upper_case' }, { command: 'variable-conversion.toDotPascalCase', - targetCase: SupportCase.DOT_PASCAL_CASE, + targetCase: SupportVariableCase.DOT_PASCAL_CASE, settingsKey: 'dot_pascal_case' }, { command: 'variable-conversion.toDotCamelCase', - targetCase: SupportCase.DOT_CAMEL_CASE, + targetCase: SupportVariableCase.DOT_CAMEL_CASE, settingsKey: 'dot_camel_case' }, // +++++++++++++++++++++++++++++++++++++++++++++++ { command: 'variable-conversion.toLowerCase', - targetCase: SupportCase.LOWER_CASE, + targetCase: SupportVariableCase.LOWER_CASE, settingsKey: 'lower_case' }, { command: 'variable-conversion.toUpperCase', - targetCase: SupportCase.UPPER_CASE, + targetCase: SupportVariableCase.UPPER_CASE, settingsKey: 'upper_case' }, ]; export interface QuickPickSupportCaseItem { - type: SupportCase, + type: SupportVariableCase, name: string, shortName: string, keyword: string[], @@ -403,140 +403,140 @@ export interface QuickPickSupportCaseItem { */ export const quickPickSupportCases: Array = [ { - type: SupportCase.CAMEL_CASE, + type: SupportVariableCase.CAMEL_CASE, name: '小驼峰(驼峰)命名', shortName: '小驼峰', keyword: keyword.camel, settingsKey: 'camel_case', }, { - type: SupportCase.PASCAL_CASE, + type: SupportVariableCase.PASCAL_CASE, name: '大驼峰(帕斯卡)命名', shortName: '帕斯卡', keyword: keyword.pascal, settingsKey: 'pascal_case', }, { - type: SupportCase.SNAKE_CASE, + type: SupportVariableCase.SNAKE_CASE, name: '下划线(蛇形)命名', shortName: '蛇形', keyword: [...keyword.snake, ...keyword.lower], settingsKey: 'snake_case', }, { - type: SupportCase.SNAKE_CAMEL_CASE, + type: SupportVariableCase.SNAKE_CAMEL_CASE, name: '下划线(蛇形) + 小驼峰(驼峰)命名', shortName: '蛇形驼峰', keyword: [...keyword.snake, ...keyword.camel], settingsKey: 'snake_camel_case', }, { - type: SupportCase.SNAKE_PASCAL_CASE, + type: SupportVariableCase.SNAKE_PASCAL_CASE, name: '下划线(蛇形) + 大驼峰(帕斯卡)命名', shortName: '蛇形帕斯卡', keyword: [...keyword.snake, ...keyword.pascal], settingsKey: 'snake_pascal_case', }, { - type: SupportCase.SNAKE_UPPER_CASE, + type: SupportVariableCase.SNAKE_UPPER_CASE, name: '下划线(蛇形) + 全大写命名', shortName: '蛇形大写', keyword: [...keyword.snake, ...keyword.upper], settingsKey: 'snake_upper_case', }, { - type: SupportCase.KEBAB_CASE, + type: SupportVariableCase.KEBAB_CASE, name: '中划线(连字符/脊柱式)命名', shortName: '脊柱', keyword: [...keyword.kebab, ...keyword.lower], settingsKey: 'kebab_case', }, { - type: SupportCase.KEBAB_CAMEL_CASE, + type: SupportVariableCase.KEBAB_CAMEL_CASE, name: '中划线(连字符/脊柱式) + 小驼峰(驼峰)命名', shortName: '脊柱驼峰', keyword: [...keyword.kebab, ...keyword.camel], settingsKey: 'kebab_camel_case', }, { - type: SupportCase.KEBAB_PASCAL_CASE, + type: SupportVariableCase.KEBAB_PASCAL_CASE, name: '中划线(连字符/脊柱式) + 大驼峰(帕斯卡)命名', shortName: '脊柱帕斯卡', keyword: [...keyword.kebab, ...keyword.pascal], settingsKey: 'kebab_pascal_case', }, { - type: SupportCase.KEBAB_UPPER_CASE, + type: SupportVariableCase.KEBAB_UPPER_CASE, name: '中划线(连字符/脊柱式) + 全大写命名', shortName: '脊柱大写', keyword: [...keyword.kebab, ...keyword.upper], settingsKey: 'kebab_upper_case', }, { - type: SupportCase.SPACE_CASE, + type: SupportVariableCase.SPACE_CASE, name: '空格分隔命名', shortName: '脊柱', keyword: [...keyword.space, ...keyword.lower], settingsKey: 'space_case', }, { - type: SupportCase.SPACE_CAMEL_CASE, + type: SupportVariableCase.SPACE_CAMEL_CASE, name: '空格分隔 + 小驼峰(驼峰)命名', shortName: '脊柱驼峰', keyword: [...keyword.space, ...keyword.camel], settingsKey: 'space_camel_case', }, { - type: SupportCase.SPACE_PASCAL_CASE, + type: SupportVariableCase.SPACE_PASCAL_CASE, name: '空格分隔 + 大驼峰(帕斯卡)命名', shortName: '脊柱帕斯卡', keyword: [...keyword.space, ...keyword.pascal], settingsKey: 'space_pascal_case', }, { - type: SupportCase.SPACE_UPPER_CASE, + type: SupportVariableCase.SPACE_UPPER_CASE, name: '空格分隔 + 全大写命名', shortName: '脊柱大写', keyword: [...keyword.space, ...keyword.upper], settingsKey: 'space_upper_case', }, { - type: SupportCase.DOT_CASE, + type: SupportVariableCase.DOT_CASE, name: '点分隔命名', shortName: '脊柱', keyword: [...keyword.dot, ...keyword.lower], settingsKey: 'dot_case', }, { - type: SupportCase.DOT_CAMEL_CASE, + type: SupportVariableCase.DOT_CAMEL_CASE, name: '点分隔 + 小驼峰(驼峰)命名', shortName: '脊柱驼峰', keyword: [...keyword.dot, ...keyword.camel], settingsKey: 'dot_camel_case', }, { - type: SupportCase.DOT_PASCAL_CASE, + type: SupportVariableCase.DOT_PASCAL_CASE, name: '点分隔 + 大驼峰(帕斯卡)命名', shortName: '脊柱帕斯卡', keyword: [...keyword.dot, ...keyword.pascal], settingsKey: 'dot_pascal_case', }, { - type: SupportCase.DOT_UPPER_CASE, + type: SupportVariableCase.DOT_UPPER_CASE, name: '点分隔 + 全大写命名', shortName: '脊柱大写', keyword: [...keyword.dot, ...keyword.upper], settingsKey: 'dot_upper_case', }, { - type: SupportCase.LOWER_CASE, + type: SupportVariableCase.LOWER_CASE, name: '全小写', shortName: '小写', keyword: keyword.lower, settingsKey: 'lower_case', }, { - type: SupportCase.UPPER_CASE, + type: SupportVariableCase.UPPER_CASE, name: '全大写', shortName: '大写', keyword: keyword.upper, @@ -545,7 +545,7 @@ export const quickPickSupportCases: Array = [ ]; export interface CyclicConvertCaseOrderItem { - type: SupportCase, + type: SupportVariableCase, settingsKey: string, } @@ -554,28 +554,28 @@ export interface CyclicConvertCaseOrderItem { * @since 2024-04-08 */ export const cyclicConvertCaseOrder: Array = [ - { type: SupportCase.CAMEL_CASE, settingsKey: 'camel_case' }, - { type: SupportCase.SNAKE_CASE, settingsKey: 'snake_case' }, - { type: SupportCase.PASCAL_CASE, settingsKey: 'pascal_case' }, - { type: SupportCase.KEBAB_CASE, settingsKey: 'kebab_case' }, - { type: SupportCase.SPACE_CASE, settingsKey: 'space_case' }, - { type: SupportCase.DOT_CASE, settingsKey: 'dot_case' }, + { type: SupportVariableCase.CAMEL_CASE, settingsKey: 'camel_case' }, + { type: SupportVariableCase.SNAKE_CASE, settingsKey: 'snake_case' }, + { type: SupportVariableCase.PASCAL_CASE, settingsKey: 'pascal_case' }, + { type: SupportVariableCase.KEBAB_CASE, settingsKey: 'kebab_case' }, + { type: SupportVariableCase.SPACE_CASE, settingsKey: 'space_case' }, + { type: SupportVariableCase.DOT_CASE, settingsKey: 'dot_case' }, - { type: SupportCase.SNAKE_UPPER_CASE, settingsKey: 'snake_upper_case' }, - { type: SupportCase.KEBAB_UPPER_CASE, settingsKey: 'kebab_upper_case' }, - { type: SupportCase.SPACE_UPPER_CASE, settingsKey: 'space_upper_case' }, - { type: SupportCase.DOT_UPPER_CASE, settingsKey: 'dot_upper_case' }, + { type: SupportVariableCase.SNAKE_UPPER_CASE, settingsKey: 'snake_upper_case' }, + { type: SupportVariableCase.KEBAB_UPPER_CASE, settingsKey: 'kebab_upper_case' }, + { type: SupportVariableCase.SPACE_UPPER_CASE, settingsKey: 'space_upper_case' }, + { type: SupportVariableCase.DOT_UPPER_CASE, settingsKey: 'dot_upper_case' }, - { type: SupportCase.SNAKE_PASCAL_CASE, settingsKey: 'snake_pascal_case' }, - { type: SupportCase.KEBAB_PASCAL_CASE, settingsKey: 'kebab_pascal_case' }, - { type: SupportCase.SPACE_PASCAL_CASE, settingsKey: 'space_pascal_case' }, - { type: SupportCase.DOT_PASCAL_CASE, settingsKey: 'dot_pascal_case' }, + { type: SupportVariableCase.SNAKE_PASCAL_CASE, settingsKey: 'snake_pascal_case' }, + { type: SupportVariableCase.KEBAB_PASCAL_CASE, settingsKey: 'kebab_pascal_case' }, + { type: SupportVariableCase.SPACE_PASCAL_CASE, settingsKey: 'space_pascal_case' }, + { type: SupportVariableCase.DOT_PASCAL_CASE, settingsKey: 'dot_pascal_case' }, - { type: SupportCase.SNAKE_CAMEL_CASE, settingsKey: 'snake_camel_case' }, - { type: SupportCase.KEBAB_CAMEL_CASE, settingsKey: 'kebab_camel_case' }, - { type: SupportCase.SPACE_CAMEL_CASE, settingsKey: 'space_camel_case' }, - { type: SupportCase.DOT_CAMEL_CASE, settingsKey: 'dot_camel_case' }, + { type: SupportVariableCase.SNAKE_CAMEL_CASE, settingsKey: 'snake_camel_case' }, + { type: SupportVariableCase.KEBAB_CAMEL_CASE, settingsKey: 'kebab_camel_case' }, + { type: SupportVariableCase.SPACE_CAMEL_CASE, settingsKey: 'space_camel_case' }, + { type: SupportVariableCase.DOT_CAMEL_CASE, settingsKey: 'dot_camel_case' }, - { type: SupportCase.LOWER_CASE, settingsKey: 'lower_case' }, - { type: SupportCase.UPPER_CASE, settingsKey: 'upper_case' }, + { type: SupportVariableCase.LOWER_CASE, settingsKey: 'lower_case' }, + { type: SupportVariableCase.UPPER_CASE, settingsKey: 'upper_case' }, ]; diff --git a/src/extension-handler/status-bar-handler.ts b/src/extension-handler/status-bar-handler.ts deleted file mode 100644 index cca2e05..0000000 --- a/src/extension-handler/status-bar-handler.ts +++ /dev/null @@ -1,36 +0,0 @@ -import * as vscode from 'vscode'; - -// docs: https://code.visualstudio.com/api/references/vscode-api#StatusBarItem - -let statusBar: vscode.StatusBarItem; - -/** - * 创建状态栏按钮 - * - * @since 2024-04-07 - */ -export function createStatusBarItem() { - statusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left); - statusBar.text = '$(find-replace)变量转换'; - statusBar.command = 'variable-conversion.convertCase'; - // statusBar.color = 'red'; - // statusBar.show(); -} - -/** - * 判断是否展示状态栏按钮 - * - * @since 2024-04-07 - */ -export function updateStatusBarItemVisable(selectTextLength: number) { - if (!statusBar) { - return; - } - - let editor = vscode.window.activeTextEditor; - if (editor && selectTextLength > 0) { - statusBar.show(); - return; - } - statusBar.hide(); -} \ No newline at end of file diff --git a/src/extension.ts b/src/extension.ts index 5e6464f..5ce8f1e 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,13 +1,33 @@ -// The module 'vscode' contains the VS Code extensibility API -// Import the module and reference it with the alias vscode in your code below +/** + * @file extension.ts + * @description 该文件包含了 VS Code 插件的主要扩展逻辑,包括命令注册、菜单配置和编辑器事件监听等。 + * @author coder-xiaomo + * @version 1.0.0 + * @license MIT + * + * 本文件是插件的核心文件,负责扩展命令的注册以及编辑器中各种事件的处理。通过监听编辑器的选择状态, + * 动态更新命令行为。插件在启动时会初始化必要的命令,并根据编辑器状态决定是否启用相关功能。 + * + * @see https://code.visualstudio.com/api + */ import * as vscode from 'vscode'; -import handleEditorReplace from './extension-handler/editor-submenu-handler'; -import { handleQuickPick } from './extension-handler/quick-pick-handler'; -import { commands } from './type-definition/SupportCaseType'; -import { createStatusBarItem, updateStatusBarItemVisable } from './extension-handler/status-bar-handler'; -import * as CyclicConversion from './main-code/cyclic-conversion'; -import { EOL } from './type-definition/EOLType'; -import { getUserConfigurations } from './main-code/user-configuration'; + +// Variable Convert +import handleEditorReplaceVariable from './handler/variable-convert/editor-submenu-handler'; +import { handleQuickPick as handleQuickPickVariable } from './handler/variable-convert/quick-pick-handler'; +import { commands as variableCommands } from './core/variable-convert/types/SupportVariableCaseType'; +import * as CyclicConversionVariable from './core/variable-convert/cyclic-conversion'; + +// Path Convert +import handleEditorReplacePath from './handler/path-convert/editor-submenu-handler'; +import { handleQuickPick as handleQuickPickPath } from './handler/path-convert/quick-pick-handler'; +import { commands as pathCommands } from './core/path-convert/types/SupportPathFormatType'; +import * as CyclicConversionPath from './core/path-convert/cyclic-conversion'; + +// Common +import { createStatusBarItem, updateStatusBarItemVisable } from './handler/status-bar-handler'; +import { EOL } from './types/EOLType'; +import { getUserConfigurations } from './utils/user-configuration'; // This method is called when your extension is activated // Your extension is activated the very first time the command is executed @@ -44,18 +64,27 @@ export function activate(context: vscode.ExtensionContext) { // issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1 // 获取用户配置 - const disableFormatList = getUserConfigurations('disableFormat'); + const disableFormatList = getUserConfigurations>('disableFormat') || []; + const disablePathFormatList = getUserConfigurations>('disablePathFormat') || []; // 更新右键菜单每一项是否展示 - for (const { settingsKey } of commands) { + // 变量转换右键菜单visible 2024.07.29 + for (const { settingsKey } of variableCommands) { vscode.commands.executeCommand('setContext', '_isHideSubMenuItem_' + settingsKey, disableFormatList.includes(settingsKey)); } + // 路径转换右键菜单visible 2024.12.14 + for (const { settingsKey } of pathCommands) { + vscode.commands.executeCommand('setContext', '_isHideSubMenuItem_' + settingsKey, disablePathFormatList.includes(settingsKey)); + } // 判断是否展示状态栏按钮 updateStatusBarItemVisable(selectTextLength); // 循环转换:记录当前选中内容,并且进行转换 let eol: EOL = textEditor.document.eol === vscode.EndOfLine.CRLF ? '\r\n' : '\n'; - CyclicConversion.onUserSelectionUpdated(selections, textList, eol); + // 变量循环转换 2024.04.09 + CyclicConversionVariable.onUserSelectionUpdated(selections, textList, eol); + // 路径循环转换 2024.12.14 + CyclicConversionPath.onUserSelectionUpdated(selections, textList, eol); }; // 创建状态栏按钮 @@ -95,29 +124,70 @@ export function activate(context: vscode.ExtensionContext) { onTextEditorSelectionChangeCallback(editor, editor.selections); } + + /** + * 变量转换 + * + * @since 2024-04 + */ + // 逐一注册右键菜单-子菜单项 command - for (const { command, targetCase } of commands) { + for (const { command, targetCase } of variableCommands) { let disposable = vscode.commands.registerCommand(command, () => { - handleEditorReplace(targetCase); + // 变量转换右键菜单 2024.04.05 + handleEditorReplaceVariable(targetCase); }); context.subscriptions.push(disposable); } // 注册变量转换 command 状态栏/快捷键/右键[变量转换]菜单均有用到 - let convertCaseDisposable = vscode.commands.registerCommand('variable-conversion.convertCase', handleQuickPick); + let convertCaseDisposable = vscode.commands.registerCommand('variable-conversion.convertCase', handleQuickPickVariable); context.subscriptions.push(convertCaseDisposable); // 注册循环转换 command - let disposableLoopConversionPrev = vscode.commands.registerCommand('variable-conversion.cyclicConvertCase.previous', ({ arrowKey }) => { - console.log('variable-conversion.convertCase', arrowKey); - CyclicConversion.previousOne(); + let loopConvertCasePrevDisposable = vscode.commands.registerCommand('variable-conversion.cyclicConvertCase.previous', ({ arrowKey }) => { + console.log('variable-conversion.cyclicConvertCase.previous', arrowKey); + CyclicConversionVariable.previousOne(); }); - context.subscriptions.push(disposableLoopConversionPrev); - let disposableLoopConversionNext = vscode.commands.registerCommand('variable-conversion.cyclicConvertCase.next', ({ arrowKey }) => { - console.log('variable-conversion.convertCase', arrowKey); - CyclicConversion.nextOne(); + context.subscriptions.push(loopConvertCasePrevDisposable); + let loopConvertCaseNextDisposable = vscode.commands.registerCommand('variable-conversion.cyclicConvertCase.next', ({ arrowKey }) => { + console.log('variable-conversion.cyclicConvertCase.next', arrowKey); + CyclicConversionVariable.nextOne(); }); - context.subscriptions.push(disposableLoopConversionNext); + context.subscriptions.push(loopConvertCaseNextDisposable); + + + /** + * 路径转换 + * issue: #3 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/3 + * + * @since 2024-12 + */ + + // 逐一注册右键菜单-子菜单项 command + for (const { command, targetCase } of pathCommands) { + let disposable = vscode.commands.registerCommand(command, () => { + // 变量转换右键菜单 2024.12.14 + handleEditorReplacePath(targetCase); + }); + context.subscriptions.push(disposable); + } + + // 注册路径转换 command 状态栏/快捷键/右键[路径转换]菜单均有用到 + let convertPathDisposable = vscode.commands.registerCommand('variable-conversion.convertPath', handleQuickPickPath); + context.subscriptions.push(convertPathDisposable); + + // 注册循环转换 command + let loopConvertPathPrevDisposable = vscode.commands.registerCommand('variable-conversion.cyclicConvertPath.previous', ({ direction }) => { + console.log('variable-conversion.cyclicConvertPath.previous', direction); + CyclicConversionPath.previousOne(); + }); + context.subscriptions.push(loopConvertPathPrevDisposable); + let loopConvertPathNextDisposable = vscode.commands.registerCommand('variable-conversion.cyclicConvertPath.next', ({ direction }) => { + console.log('variable-conversion.cyclicConvertPath.next', direction); + CyclicConversionPath.nextOne(); + }); + context.subscriptions.push(loopConvertPathNextDisposable); } // This method is called when your extension is deactivated diff --git a/src/handler/path-convert/editor-submenu-handler.ts b/src/handler/path-convert/editor-submenu-handler.ts new file mode 100644 index 0000000..97c0526 --- /dev/null +++ b/src/handler/path-convert/editor-submenu-handler.ts @@ -0,0 +1,59 @@ +import * as vscode from 'vscode'; +import { EOL } from '../../types/EOLType'; +import { pathConversion } from '../../core/path-convert/conversion'; +import { SupportPathFormat } from '../../core/path-convert/types/SupportPathFormatType'; +import { isStringArrayEqual } from '../../utils/utils'; + +/** + * 编辑器右键菜单 + * + * @param convertFunction + * @returns + */ +const handleEditorReplace = (targetCase: SupportPathFormat) => { + // 获取当前编辑器 + let editor = vscode.window.activeTextEditor; + if (!editor) { + return; + } + + const document = editor.document; + const selections = editor.selections; + const eol: EOL = document.eol === vscode.EndOfLine.CRLF ? '\r\n' : '\n'; + + // 获取选中的文本 + const textList = selections.map(selection => document.getText(selection)); + + if (textList.filter(text => text.length > 0).length === 0) { + vscode.window.showInformationMessage('请选择需要转换的路径后重试\nPlease select the path you want to convert and try again.'); + return; + } + + // 转换文本 + const convertedList = textList.map(text => pathConversion(targetCase, text, eol)); + console.log('convertedList', convertedList); + + // 无法转换时,跳过转换 + if (convertedList.filter(converted => converted !== undefined).length === 0) { + console.log('converted text is undefined, skip replace contents.'); + return; + } + + // 当转换后文本与转换前相同时,跳过转换,避免形成 Ctrl + Z 撤销历史记录 + if (isStringArrayEqual(convertedList, textList)) { + console.log('selection text is same to converted text, skip replace contents.'); + return; + } + + // 替换文本 + console.log('replace selection text', textList, 'to', convertedList); + editor.edit(editBuilder => { + for (let i = 0; i < selections.length; i++) { + const selection = selections[i]; + const converted = convertedList[i]; + editBuilder.replace(selection, converted); + } + }); +}; + +export default handleEditorReplace; diff --git a/src/handler/path-convert/quick-pick-handler.ts b/src/handler/path-convert/quick-pick-handler.ts new file mode 100644 index 0000000..a1c7833 --- /dev/null +++ b/src/handler/path-convert/quick-pick-handler.ts @@ -0,0 +1,144 @@ +import * as vscode from 'vscode'; +import QuickPickItemEx from "../types/QuickPickItemExType"; +import { QuickPickSupportCaseItem, quickPickSupportCases } from '../../core/path-convert/types/SupportPathFormatType'; +import { TransformTextResult } from '../../types/TransformTextResultType'; +import { transformMutliSelectionText } from '../../utils/transform'; +import { EOL } from '../../types/EOLType'; +import { pathConversion } from '../../core/path-convert/conversion'; +import { isStringArrayEqual } from '../../utils/utils'; +import { getUserConfigurations } from '../../utils/user-configuration'; + +const QuickPickLabelMaxLength = 60; + +interface RecommendItem { + conversionText: Array + transforTo: string[] + keyword: string[] +} + +/** + * 弹出的提示 + * + * @since 2024-12-14 + */ +function generateOptionsBasedOnText(textList: string[], eol: EOL, enabledQuickPickSupportCases: Array): Array { + // Cut text 切割文本 + const resultsList: Array = transformMutliSelectionText(textList); + + const mergeResultList: Array = []; + for (const quickPick of enabledQuickPickSupportCases) { + const conversionResults: Array = []; + for (let i = 0; i < textList.length; i++) { + const text = textList[i]; + const results = resultsList[i]; + const conversionResult: string = pathConversion(quickPick.type, text, eol, results); + conversionResults.push(conversionResult); + } + const recommendItem: RecommendItem | undefined = mergeResultList.find(item => isStringArrayEqual(item.conversionText, conversionResults)); + + if (recommendItem === undefined) { + let item: RecommendItem = { + conversionText: conversionResults, + transforTo: [quickPick.shortName], // quickPick.name + keyword: quickPick.keyword, + }; + mergeResultList.push(item); + continue; + } + + recommendItem.transforTo.push(quickPick.shortName); // quickPick.name + recommendItem.keyword = Array.from(new Set(recommendItem.keyword.concat(quickPick.keyword))); // 关键词去重 + } + + // 根据文本生成选项的逻辑 + const quickPickList = []; + + for (const recommendItem of mergeResultList) { + if (isStringArrayEqual(textList, recommendItem.conversionText)) { + continue; // 如果转换后与转换前相同,那么跳过这一项 + } + const conversionTextForDisplay = recommendItem.conversionText.join(' ').replace(/\s+/g, " "); // 友好展示 将连续空格 \n \t 等替换为单一空格 + let quickPickItem: QuickPickItemEx = { + label: conversionTextForDisplay.length >= QuickPickLabelMaxLength + ? (conversionTextForDisplay.substring(0, QuickPickLabelMaxLength - 3) + '...') + : conversionTextForDisplay, + description: `转换为 ${recommendItem.transforTo.join(' / ')}`, + detail: `关键词 ${recommendItem.keyword.join(' ')}`, + value: recommendItem.conversionText, + }; + quickPickList.push(quickPickItem); + } + return quickPickList; +} + +export function handleQuickPick() { + // 获取当前编辑器 + let editor = vscode.window.activeTextEditor; + if (!editor) { + return; + } + + const document = editor.document; + const selections = editor.selections; + const eol: EOL = document.eol === vscode.EndOfLine.CRLF ? '\r\n' : '\n'; + + // 获取选中的文本 + const textList = selections.map(selection => document.getText(selection)); + + if (textList.filter(text => text.length > 0).length === 0) { + vscode.window.showInformationMessage('请选择需要转换的路径后重试\nPlease select the path you want to convert and try again.'); + return; + } + + // TODO + // 获取用户配置 + const disablePathFormatList = getUserConfigurations>('disablePathFormat') || []; + // 排除禁用的选项 + const enabledQuickPickSupportCases = []; + for (const quickPick of quickPickSupportCases) { + if (disablePathFormatList.includes(quickPick.settingsKey)) { + continue; + } + enabledQuickPickSupportCases.push(quickPick); + } + if (enabledQuickPickSupportCases.length === 0) { + vscode.window.showInformationMessage('所有格式都已被配置为禁用,请修改配置 `variable-conversion.disablePathFormat` 后重试\nAll formats have been configured to disable. Modify the `variable-conversion.disablePathFormat` configuration and try again.'); + return; + } + + // 基于选中的文本生成选项 + const options = generateOptionsBasedOnText(textList, eol, enabledQuickPickSupportCases); + if (options.length === 0) { + vscode.window.showInformationMessage('所选内容暂无可选转换,请尝试重新选择\nNo conversion candidates are available for the selected content, please try to select another text.'); + return; + } + + // 显示推荐项列表 + vscode.window.showQuickPick(options, { + matchOnDetail: true, + title: '请选择需要转换的路径风格...', + placeHolder: '点击转换,输入关键词可快速选择' + }).then(pickItem => { + if (!editor || pickItem === undefined) { + return; + } + + const convertedList = pickItem.value; + + // 当转换后文本与转换前相同时,跳过转换,避免形成 Ctrl + Z 撤销历史记录 + if (isStringArrayEqual(convertedList, textList)) { + console.log('selection text is same to converted text, skip replace contents.'); + return; + } + + // 替换文本 + console.log('replace selection text', textList, 'to', convertedList); + editor.edit(editBuilder => { + for (let i = 0; i < selections.length; i++) { + const selection = selections[i]; + const converted = convertedList[i]; + editBuilder.replace(selection, converted); + } + }); + }); +} diff --git a/src/handler/status-bar-handler.ts b/src/handler/status-bar-handler.ts new file mode 100644 index 0000000..3a8d5c4 --- /dev/null +++ b/src/handler/status-bar-handler.ts @@ -0,0 +1,54 @@ +import * as vscode from 'vscode'; + +// docs: https://code.visualstudio.com/api/references/vscode-api#StatusBarItem + +let statusBarItemList: Array = []; + +/** + * 创建状态栏按钮 + * + * @since 2024-04-07 + */ +export function createStatusBarItem() { + // 变量转换状态栏 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 + statusBarItem.text = '$(find-replace)变量转换'; + statusBarItem.command = 'variable-conversion.convertCase'; + // statusBarItem.color = 'red'; + // statusBarItem.show(); + return statusBarItem; + }; + // 路径转换状态栏 2024.12.14 + const createPathConvertStatusBarItem = () => { + const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left); + statusBarItem.text = '$(sync-ignored)路径转换'; // italic symbol-null + statusBarItem.command = 'variable-conversion.convertPath'; + statusBarItemList.push(statusBarItem); + return statusBarItem; + }; + + statusBarItemList.push( + createVariableConvertStatusBarItem(), + createPathConvertStatusBarItem(), + ); +} + +/** + * 判断是否展示状态栏按钮 + * + * @since 2024-04-07 + */ +export function updateStatusBarItemVisable(selectTextLength: number) { + let editor = vscode.window.activeTextEditor; + if (editor && selectTextLength > 0) { + statusBarItemList.forEach(statusBarItem => { + statusBarItem.show(); + }); + return; + } + statusBarItemList.forEach(statusBarItem => { + statusBarItem.hide(); + }); +} \ No newline at end of file diff --git a/src/type-definition/QuickPickItemExType.ts b/src/handler/types/QuickPickItemExType.ts similarity index 100% rename from src/type-definition/QuickPickItemExType.ts rename to src/handler/types/QuickPickItemExType.ts diff --git a/src/extension-handler/editor-submenu-handler.ts b/src/handler/variable-convert/editor-submenu-handler.ts similarity index 84% rename from src/extension-handler/editor-submenu-handler.ts rename to src/handler/variable-convert/editor-submenu-handler.ts index 2c599ae..3abf0fc 100644 --- a/src/extension-handler/editor-submenu-handler.ts +++ b/src/handler/variable-convert/editor-submenu-handler.ts @@ -1,8 +1,8 @@ import * as vscode from 'vscode'; -import { EOL } from '../type-definition/EOLType'; -import { caseConversion } from '../main-code/conversion'; -import { SupportCase } from '../type-definition/SupportCaseType'; -import { isStringArrayEqual } from '../main-code/utils'; +import { EOL } from '../../types/EOLType'; +import { caseConversion } from '../../core/variable-convert/conversion'; +import { SupportVariableCase } from '../../core/variable-convert/types/SupportVariableCaseType'; +import { isStringArrayEqual } from '../../utils/utils'; /** * 编辑器右键菜单 @@ -10,7 +10,7 @@ import { isStringArrayEqual } from '../main-code/utils'; * @param convertFunction * @returns */ -const handleEditorReplace = (targetCase: SupportCase) => { +const handleEditorReplace = (targetCase: SupportVariableCase) => { // 获取当前编辑器 let editor = vscode.window.activeTextEditor; if (!editor) { diff --git a/src/extension-handler/quick-pick-handler.ts b/src/handler/variable-convert/quick-pick-handler.ts similarity index 90% rename from src/extension-handler/quick-pick-handler.ts rename to src/handler/variable-convert/quick-pick-handler.ts index 295cc2a..cadb8ad 100644 --- a/src/extension-handler/quick-pick-handler.ts +++ b/src/handler/variable-convert/quick-pick-handler.ts @@ -1,12 +1,12 @@ import * as vscode from 'vscode'; -import QuickPickItemEx from "../type-definition/QuickPickItemExType"; -import { QuickPickSupportCaseItem, quickPickSupportCases } from '../type-definition/SupportCaseType'; -import { TransformTextResult } from '../type-definition/TransformTextResultType'; -import { transformMutliSelectionText } from '../main-code/transform'; -import { EOL } from '../type-definition/EOLType'; -import { caseConversion } from '../main-code/conversion'; -import { isStringArrayEqual } from '../main-code/utils'; -import { getUserConfigurations } from '../main-code/user-configuration'; +import QuickPickItemEx from "../types/QuickPickItemExType"; +import { QuickPickSupportCaseItem, quickPickSupportCases } from '../../core/variable-convert/types/SupportVariableCaseType'; +import { TransformTextResult } from '../../types/TransformTextResultType'; +import { transformMutliSelectionText } from '../../utils/transform'; +import { EOL } from '../../types/EOLType'; +import { caseConversion } from '../../core/variable-convert/conversion'; +import { isStringArrayEqual } from '../../utils/utils'; +import { getUserConfigurations } from '../../utils/user-configuration'; const QuickPickLabelMaxLength = 60; @@ -98,7 +98,7 @@ export function handleQuickPick() { // issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1 // 获取用户配置 - const disableFormatList = getUserConfigurations('disableFormat'); + const disableFormatList = getUserConfigurations>('disableFormat') || []; // 排除禁用的选项 const enabledQuickPickSupportCases = []; for (const quickPick of quickPickSupportCases) { @@ -122,7 +122,7 @@ export function handleQuickPick() { // 显示推荐项列表 vscode.window.showQuickPick(options, { matchOnDetail: true, - title: '请选择需要转换的命名类型...', + title: '请选择需要转换的命名方式...', placeHolder: '点击转换,输入关键词可快速选择' }).then(pickItem => { if (!editor || pickItem === undefined) { diff --git a/src/main-code/user-configuration.ts b/src/main-code/user-configuration.ts deleted file mode 100644 index 4a9d106..0000000 --- a/src/main-code/user-configuration.ts +++ /dev/null @@ -1,14 +0,0 @@ -const vscode = require('vscode'); - -function getUserConfigurations(configKey: string) { - const config = vscode.workspace.getConfiguration('variable-conversion'); - - // 获取 disableFormat 配置项 - const configValue = config.get(configKey); - console.log('configValue:', configValue); - return configValue; -} - -export { - getUserConfigurations -}; diff --git a/src/test/extension.test.ts b/src/test/extension.test.ts index 8b434e7..cdae582 100644 --- a/src/test/extension.test.ts +++ b/src/test/extension.test.ts @@ -3,12 +3,16 @@ import * as assert from 'assert'; // You can import and use all API from the 'vscode' module // as well as import your extension to test it import * as vscode from 'vscode'; -import testGroups from './test-case'; -import { TestCase, TestCaseGroup } from '../type-definition/TestCaseType'; -import { transformMutliLineText, transformText } from '../main-code/transform'; -import { caseConversion } from '../main-code/conversion'; -import { SupportCase } from '../type-definition/SupportCaseType'; -import { TransformTextResult } from '../type-definition/TransformTextResultType'; +import { variableConvertTestGroups } from './test-case/variable-convert-test-case'; +import { pathConvertTestGroups } from './test-case/path-convert-test-case'; +import { VariableTestCase, VariableTestCaseGroup } from './test-case/types/VariableTestCaseType'; +import { PathTestCase, PathTestCaseGroup } from './test-case/types/PathTestCaseType'; +import { transformMutliLineText, transformText } from '../utils/transform'; +import { caseConversion } from '../core/variable-convert/conversion'; +import { pathConversion } from '../core/path-convert/conversion'; +import { SupportVariableCase } from '../core/variable-convert/types/SupportVariableCaseType'; +import { SupportPathFormat } from '../core/path-convert/types/SupportPathFormatType'; +import { TransformTextResult } from '../types/TransformTextResultType'; // import * as myExtension from '../../extension'; /* @@ -22,13 +26,18 @@ suite('Extension Test Suite', () => { }); */ -suite('Extension Test: run test case', () => { - vscode.window.showInformationMessage('Start all tests.'); +/** + * 变量转换 测试函数 + * + * @since 2024-04-02 + */ +suite('Extension Test: run variable convert test case', () => { + vscode.window.showInformationMessage('Start all tests for variable conversion.'); - const groups: Array = testGroups; + const groups: Array = variableConvertTestGroups; for (const testGroup of groups) { const testTitle = testGroup.testTitle; - const testCases: Array = testGroup.cases; + const testCases: Array = testGroup.cases; for (const testCase of testCases) { // // 临时 // if (testCase.title !== '') { @@ -48,35 +57,35 @@ suite('Extension Test: run test case', () => { assert.strictEqual(correctValue, currentValue); } // 验证转换 - for (let eol of eolList) { - assert.strictEqual(testCase.output.camelCase, caseConversion(SupportCase.CAMEL_CASE, input, eol), 'camel case test failed.'); - assert.strictEqual(testCase.output.pascalCase, caseConversion(SupportCase.PASCAL_CASE, input, eol), 'pascal case test failed.'); + for (const eol of eolList) { + assert.strictEqual(testCase.output.camelCase, caseConversion(SupportVariableCase.CAMEL_CASE, input, eol), 'camel case test failed.'); + assert.strictEqual(testCase.output.pascalCase, caseConversion(SupportVariableCase.PASCAL_CASE, input, eol), 'pascal case test failed.'); - assert.strictEqual(testCase.output.snakeCase, caseConversion(SupportCase.SNAKE_CASE, input, eol), 'snake case test failed.'); - assert.strictEqual(testCase.output.snakeCamelCase, caseConversion(SupportCase.SNAKE_CAMEL_CASE, input, eol), 'snake camel case test failed.'); - assert.strictEqual(testCase.output.snakePascalCase, caseConversion(SupportCase.SNAKE_PASCAL_CASE, input, eol), 'snake pascal case test failed.'); - assert.strictEqual(testCase.output.snakeUpperCase, caseConversion(SupportCase.SNAKE_UPPER_CASE, input, eol), 'snake upper case test failed.'); + assert.strictEqual(testCase.output.snakeCase, caseConversion(SupportVariableCase.SNAKE_CASE, input, eol), 'snake case test failed.'); + assert.strictEqual(testCase.output.snakeCamelCase, caseConversion(SupportVariableCase.SNAKE_CAMEL_CASE, input, eol), 'snake camel case test failed.'); + assert.strictEqual(testCase.output.snakePascalCase, caseConversion(SupportVariableCase.SNAKE_PASCAL_CASE, input, eol), 'snake pascal case test failed.'); + assert.strictEqual(testCase.output.snakeUpperCase, caseConversion(SupportVariableCase.SNAKE_UPPER_CASE, input, eol), 'snake upper case test failed.'); - assert.strictEqual(testCase.output.kebabCase, caseConversion(SupportCase.KEBAB_CASE, input, eol), 'kebab case test failed.'); - assert.strictEqual(testCase.output.kebabCamelCase, caseConversion(SupportCase.KEBAB_CAMEL_CASE, input, eol), 'kebab camel case test failed.'); - assert.strictEqual(testCase.output.kebabPascalCase, caseConversion(SupportCase.KEBAB_PASCAL_CASE, input, eol), 'kebab pascal case test failed.'); - assert.strictEqual(testCase.output.kebabUpperCase, caseConversion(SupportCase.KEBAB_UPPER_CASE, input, eol), 'kebab upper case test failed.'); + assert.strictEqual(testCase.output.kebabCase, caseConversion(SupportVariableCase.KEBAB_CASE, input, eol), 'kebab case test failed.'); + assert.strictEqual(testCase.output.kebabCamelCase, caseConversion(SupportVariableCase.KEBAB_CAMEL_CASE, input, eol), 'kebab camel case test failed.'); + assert.strictEqual(testCase.output.kebabPascalCase, caseConversion(SupportVariableCase.KEBAB_PASCAL_CASE, input, eol), 'kebab pascal case test failed.'); + assert.strictEqual(testCase.output.kebabUpperCase, caseConversion(SupportVariableCase.KEBAB_UPPER_CASE, input, eol), 'kebab upper case test failed.'); - assert.strictEqual(testCase.output.spaceCase, caseConversion(SupportCase.SPACE_CASE, input, eol), 'space case test failed.'); - assert.strictEqual(testCase.output.spaceCamelCase, caseConversion(SupportCase.SPACE_CAMEL_CASE, input, eol), 'space camel case test failed.'); - assert.strictEqual(testCase.output.spacePascalCase, caseConversion(SupportCase.SPACE_PASCAL_CASE, input, eol), 'space pascal case test failed.'); - assert.strictEqual(testCase.output.spaceUpperCase, caseConversion(SupportCase.SPACE_UPPER_CASE, input, eol), 'space upper case test failed.'); + assert.strictEqual(testCase.output.spaceCase, caseConversion(SupportVariableCase.SPACE_CASE, input, eol), 'space case test failed.'); + assert.strictEqual(testCase.output.spaceCamelCase, caseConversion(SupportVariableCase.SPACE_CAMEL_CASE, input, eol), 'space camel case test failed.'); + assert.strictEqual(testCase.output.spacePascalCase, caseConversion(SupportVariableCase.SPACE_PASCAL_CASE, input, eol), 'space pascal case test failed.'); + assert.strictEqual(testCase.output.spaceUpperCase, caseConversion(SupportVariableCase.SPACE_UPPER_CASE, input, eol), 'space upper case test failed.'); - assert.strictEqual(testCase.output.dotCase, caseConversion(SupportCase.DOT_CASE, input, eol), 'dot case test failed.'); - assert.strictEqual(testCase.output.dotCamelCase, caseConversion(SupportCase.DOT_CAMEL_CASE, input, eol), 'dot camel case test failed.'); - assert.strictEqual(testCase.output.dotPascalCase, caseConversion(SupportCase.DOT_PASCAL_CASE, input, eol), 'dot pascal case test failed.'); - assert.strictEqual(testCase.output.dotUpperCase, caseConversion(SupportCase.DOT_UPPER_CASE, input, eol), 'dot upper case test failed.'); + assert.strictEqual(testCase.output.dotCase, caseConversion(SupportVariableCase.DOT_CASE, input, eol), 'dot case test failed.'); + assert.strictEqual(testCase.output.dotCamelCase, caseConversion(SupportVariableCase.DOT_CAMEL_CASE, input, eol), 'dot camel case test failed.'); + assert.strictEqual(testCase.output.dotPascalCase, caseConversion(SupportVariableCase.DOT_PASCAL_CASE, input, eol), 'dot pascal case test failed.'); + assert.strictEqual(testCase.output.dotUpperCase, caseConversion(SupportVariableCase.DOT_UPPER_CASE, input, eol), 'dot upper case test failed.'); if (testCase.output.lowerCase !== undefined) { - assert.strictEqual(testCase.output.lowerCase, caseConversion(SupportCase.LOWER_CASE, input, eol), 'lower case test failed.'); + assert.strictEqual(testCase.output.lowerCase, caseConversion(SupportVariableCase.LOWER_CASE, input, eol), 'lower case test failed.'); } if (testCase.output.upperCase !== undefined) { - assert.strictEqual(testCase.output.upperCase, caseConversion(SupportCase.UPPER_CASE, input, eol), 'upper case test failed.'); + assert.strictEqual(testCase.output.upperCase, caseConversion(SupportVariableCase.UPPER_CASE, input, eol), 'upper case test failed.'); } } } @@ -84,3 +93,36 @@ suite('Extension Test: run test case', () => { } } }); + +/** + * 路径转换 测试函数 + * + * @since 2024-12-07 + */ +suite('Extension Test: run path convert test case', () => { + vscode.window.showInformationMessage('Start all tests for path conversion.'); + + const groups: Array = pathConvertTestGroups; + for (const testGroup of groups) { + const testTitle = testGroup.testTitle; + const testCases: Array = testGroup.cases; + for (const testCase of testCases) { + // // 临时 + // if (testCase.title !== '') { + // continue; + // } + test(testTitle + ' - ' + testCase.title, () => { + const inputList = Array.isArray(testCase.input) ? testCase.input : [testCase.input]; + const eolList = Array.isArray(testCase.eol) ? testCase.eol : [testCase.eol]; + for (const input of inputList) { + // console.log('input', '->' + input + '<-'); + // 验证转换 + for (const eol of eolList) { + assert.strictEqual(testCase.output.Windows.unEscape, pathConversion(SupportPathFormat.Windows, input, eol), 'Windows path format test failed.'); + assert.strictEqual(testCase.output.Unix.unEscape, pathConversion(SupportPathFormat.Unix, input, eol), 'Unix path format test failed.'); + } + } + }); + } + } +}); diff --git a/src/test/test-case/path-convert-test-case.ts b/src/test/test-case/path-convert-test-case.ts new file mode 100644 index 0000000..0287382 --- /dev/null +++ b/src/test/test-case/path-convert-test-case.ts @@ -0,0 +1,108 @@ +import { PathTestCaseGroup } from "./types/PathTestCaseType"; + +const LF = '\n'; +const CRLF = '\r\n'; + +export const pathConvertTestGroups: Array = [ + { + group: 'Normal Path Format Convert', + testTitle: 'Normal Path Format Convert (常规路径风格转换)', + cases: [ + { + title: 'Windows 风格', + input: // E:\Project\variable-conversion-vscode-extension + 'E:\\Project\\variable-conversion-vscode-extension', + eol: [LF, CRLF], + output: { + Windows: { + unEscape: // E:\Project\variable-conversion-vscode-extension + 'E:\\Project\\variable-conversion-vscode-extension', + + escape: // E:\\Project\\variable-conversion-vscode-extension + 'E:\\\\Project\\\\variable-conversion-vscode-extension', + }, + Unix: { + unEscape: + 'E:/Project/variable-conversion-vscode-extension', + escape: // E:\/Project\/variable-conversion-vscode-extension + 'E:\\/Project\\/variable-conversion-vscode-extension', + }, + }, + }, + { + title: 'Unix 风格', + input: '/home/user/file.txt', + eol: [LF, CRLF], + output: { + Windows: { + unEscape: // \home\user\file.txt + '\\home\\user\\file.txt', + escape: // \\home\\user\\file.txt + '\\\\home\\\\user\\\\file.txt', + }, + Unix: { + unEscape: + '/home/user/file.txt', + escape: // \/home\/user\/file.txt + '\\/home\\/user\\/file.txt', + }, + }, + }, + { + title: 'Windows (Git Bash) 风格', + input: '/c/Users/test/file.txt', + eol: [LF, CRLF], + output: { + Windows: { + unEscape: // \c\Users\test/file.txt + '\\c\\Users\\test\\file.txt', + escape: // \\c\\Users\\test\\file.txt + '\\\\c\\\\Users\\\\test\\\\file.txt', + // TODO need to transform to ↓ + /* + unEscape: // C:\Users\test\file.txt + 'C:\\Users\\test\\file.txt', + escape: // C:\\Users\\test\\file.txt + 'C:\\\\Users\\\\test\\\\file.txt', + */ + }, + Unix: { + unEscape: + '/c/Users/test/file.txt', + escape: // \/c\/Users\/test\/file.txt + '\\/c\\/Users\\/test\\/file.txt', + }, + }, + }, + + // TODO + // Windows 局域网主机名风格 + // \\ComputerName + // 路径带空格 + // /home/user/hello world.txt + // /home/user/hello world.txt + // and more ... + + // { + // title: '', + // input: // + // '', + // eol: [LF, CRLF], + // output: { + // Windows: { + // unEscape: // + // '', + // escape: // + // '', + // }, + // Unix: { + // unEscape: // + // '', + // escape: // + // '', + // }, + // }, + // }, + ], + }, +]; diff --git a/src/test/test-case/types/PathTestCaseType.ts b/src/test/test-case/types/PathTestCaseType.ts new file mode 100644 index 0000000..f3e15fd --- /dev/null +++ b/src/test/test-case/types/PathTestCaseType.ts @@ -0,0 +1,22 @@ +import { EOL } from "../../../types/EOLType"; + +export type PathTestCaseGroup = { + group: string + testTitle: string + cases: Array +}; + +export type PathTestOutputResult = { + unEscape: string; + escape: string; +}; + +export type PathTestCase = { + title: string + input: string | Array + eol: EOL | Array + output: { + Windows: PathTestOutputResult + Unix: PathTestOutputResult + } +}; diff --git a/src/type-definition/TestCaseType.ts b/src/test/test-case/types/VariableTestCaseType.ts similarity index 83% rename from src/type-definition/TestCaseType.ts rename to src/test/test-case/types/VariableTestCaseType.ts index 4c99d87..422b710 100644 --- a/src/type-definition/TestCaseType.ts +++ b/src/test/test-case/types/VariableTestCaseType.ts @@ -1,12 +1,12 @@ -import { EOL } from "./EOLType"; +import { EOL } from "../../../types/EOLType"; -export type TestCaseGroup = { +export type VariableTestCaseGroup = { group: string testTitle: string - cases: Array + cases: Array }; -export type TestCase = { +export type VariableTestCase = { title: string input: string | Array eol: EOL | Array diff --git a/src/test/test-case.ts b/src/test/test-case/variable-convert-test-case.ts similarity index 97% rename from src/test/test-case.ts rename to src/test/test-case/variable-convert-test-case.ts index 2d4232c..efc0f0d 100644 --- a/src/test/test-case.ts +++ b/src/test/test-case/variable-convert-test-case.ts @@ -1,1099 +1,1097 @@ -import { TestCaseGroup } from "../type-definition/TestCaseType"; - -const LF = '\n'; -const CRLF = '\r\n'; - -const testGroups: Array = [ - { - group: 'Input validation', - testTitle: 'Input validation (输入有效性验证)', - cases: [ - // 输入为空 - { - title: 'empty input', - input: '', - eol: [LF, CRLF], - transformText: [ - '', - ], - output: { - camelCase: '', - pascalCase: '', - snakeCase: '', - snakeCamelCase: '', - snakePascalCase: '', - snakeUpperCase: '', - kebabCase: '', - kebabCamelCase: '', - kebabPascalCase: '', - kebabUpperCase: '', - spaceCase: '', - spaceCamelCase: '', - spacePascalCase: '', - spaceUpperCase: '', - dotCase: '', - dotCamelCase: '', - dotPascalCase: '', - dotUpperCase: '', - lowerCase: '', - upperCase: '', - }, - }, - { - title: 'empty input (contains space)', - input: ' ', - eol: [LF, CRLF], - transformText: [ - ' ', - ], - output: { - camelCase: ' ', - pascalCase: ' ', - snakeCase: ' ', - snakeCamelCase: ' ', - snakePascalCase: ' ', - snakeUpperCase: ' ', - kebabCase: ' ', - kebabCamelCase: ' ', - kebabPascalCase: ' ', - kebabUpperCase: ' ', - spaceCase: ' ', - spaceCamelCase: ' ', - spacePascalCase: ' ', - spaceUpperCase: ' ', - dotCase: ' ', - dotCamelCase: ' ', - dotPascalCase: ' ', - dotUpperCase: ' ', - lowerCase: ' ', - upperCase: ' ', - }, - }, - { - title: 'empty input (contains space and crlf enter 1)', - input: ' \r\n ', - eol: [CRLF], - transformText: [ - ' ', - ' ', - ], - output: { - camelCase: ' \r\n ', - pascalCase: ' \r\n ', - snakeCase: ' \r\n ', - snakeCamelCase: ' \r\n ', - snakePascalCase: ' \r\n ', - snakeUpperCase: ' \r\n ', - kebabCase: ' \r\n ', - kebabCamelCase: ' \r\n ', - kebabPascalCase: ' \r\n ', - kebabUpperCase: ' \r\n ', - spaceCase: ' \r\n ', - spaceCamelCase: ' \r\n ', - spacePascalCase: ' \r\n ', - spaceUpperCase: ' \r\n ', - dotCase: ' \r\n ', - dotCamelCase: ' \r\n ', - dotPascalCase: ' \r\n ', - dotUpperCase: ' \r\n ', - lowerCase: ' \r\n ', - upperCase: ' \r\n ', - }, - }, - { - title: 'empty input (contains space and crlf enter 2)', - input: ' x \r\ny ', - eol: [CRLF], - transformText: [ - ' x ', - 'y ', - ], - output: { - camelCase: ' x \r\ny ', - pascalCase: ' X \r\nY ', - snakeCase: ' x \r\ny ', - snakeCamelCase: ' x \r\ny ', - snakePascalCase: ' X \r\nY ', - snakeUpperCase: ' X \r\nY ', - kebabCase: ' x \r\ny ', - kebabCamelCase: ' x \r\ny ', - kebabPascalCase: ' X \r\nY ', - kebabUpperCase: ' X \r\nY ', - spaceCase: ' x \r\ny ', - spaceCamelCase: ' x \r\ny ', - spacePascalCase: ' X \r\nY ', - spaceUpperCase: ' X \r\nY ', - dotCase: ' x \r\ny ', - dotCamelCase: ' x \r\ny ', - dotPascalCase: ' X \r\nY ', - dotUpperCase: ' X \r\nY ', - lowerCase: ' x \r\ny ', - upperCase: ' X \r\nY ', - }, - }, - { - title: 'empty input (contains space and lf enter 1)', - input: ' \n ', - eol: [LF], - transformText: [ - ' ', - ' ', - ], - output: { - camelCase: ' \n ', - pascalCase: ' \n ', - snakeCase: ' \n ', - snakeCamelCase: ' \n ', - snakePascalCase: ' \n ', - snakeUpperCase: ' \n ', - kebabCase: ' \n ', - kebabCamelCase: ' \n ', - kebabPascalCase: ' \n ', - kebabUpperCase: ' \n ', - spaceCase: ' \n ', - spaceCamelCase: ' \n ', - spacePascalCase: ' \n ', - spaceUpperCase: ' \n ', - dotCase: ' \n ', - dotCamelCase: ' \n ', - dotPascalCase: ' \n ', - dotUpperCase: ' \n ', - lowerCase: ' \n ', - upperCase: ' \n ', - }, - }, - { - title: 'empty input (contains space and lf enter 2)', - input: ' a\nb ', - eol: [LF], - transformText: [ - ' a', - 'b ', - ], - output: { - camelCase: ' a\nb ', - pascalCase: ' A\nB ', - snakeCase: ' a\nb ', - snakeCamelCase: ' a\nb ', - snakePascalCase: ' A\nB ', - snakeUpperCase: ' A\nB ', - kebabCase: ' a\nb ', - kebabCamelCase: ' a\nb ', - kebabPascalCase: ' A\nB ', - kebabUpperCase: ' A\nB ', - spaceCase: ' a\nb ', - spaceCamelCase: ' a\nb ', - spacePascalCase: ' A\nB ', - spaceUpperCase: ' A\nB ', - dotCase: ' a\nb ', - dotCamelCase: ' a\nb ', - dotPascalCase: ' A\nB ', - dotUpperCase: ' A\nB ', - lowerCase: ' a\nb ', - upperCase: ' A\nB ', - }, - }, - // 输入长文本 - { - title: 'long text input', - input: - `China's factory activity expanded in March after five consecutive months of contraction, an official survey revealed on Sunday, adding to a run of indicators that suggest the stabilization of the world's second-largest economy.` - , - eol: [LF, CRLF], - transformText: [ - "china|'|s|factory|activity|expanded|in|march|after|five|consecutive|months|of|contraction|,|an|official|survey|revealed|on|sunday|,|adding|to|a|run|of|indicators|that|suggest|the|stabilization|of|the|world|'|s|second|largest|economy|." - ], - output: { - camelCase: - "china'SFactoryActivityExpandedInMarchAfterFiveConsecutiveMonthsOfContraction,AnOfficialSurveyRevealedOnSunday,AddingToARunOfIndicatorsThatSuggestTheStabilizationOfTheWorld'SSecondLargestEconomy." - , - pascalCase: - "China'SFactoryActivityExpandedInMarchAfterFiveConsecutiveMonthsOfContraction,AnOfficialSurveyRevealedOnSunday,AddingToARunOfIndicatorsThatSuggestTheStabilizationOfTheWorld'SSecondLargestEconomy." - , - snakeCase: - "china's_factory_activity_expanded_in_march_after_five_consecutive_months_of_contraction,an_official_survey_revealed_on_sunday,adding_to_a_run_of_indicators_that_suggest_the_stabilization_of_the_world's_second_largest_economy." - , - snakeCamelCase: - "china'S_Factory_Activity_Expanded_In_March_After_Five_Consecutive_Months_Of_Contraction,An_Official_Survey_Revealed_On_Sunday,Adding_To_A_Run_Of_Indicators_That_Suggest_The_Stabilization_Of_The_World'S_Second_Largest_Economy." - , - snakePascalCase: - "China'S_Factory_Activity_Expanded_In_March_After_Five_Consecutive_Months_Of_Contraction,An_Official_Survey_Revealed_On_Sunday,Adding_To_A_Run_Of_Indicators_That_Suggest_The_Stabilization_Of_The_World'S_Second_Largest_Economy." - , - snakeUpperCase: - "CHINA'S_FACTORY_ACTIVITY_EXPANDED_IN_MARCH_AFTER_FIVE_CONSECUTIVE_MONTHS_OF_CONTRACTION,AN_OFFICIAL_SURVEY_REVEALED_ON_SUNDAY,ADDING_TO_A_RUN_OF_INDICATORS_THAT_SUGGEST_THE_STABILIZATION_OF_THE_WORLD'S_SECOND_LARGEST_ECONOMY." - , - kebabCase: - "china's-factory-activity-expanded-in-march-after-five-consecutive-months-of-contraction,an-official-survey-revealed-on-sunday,adding-to-a-run-of-indicators-that-suggest-the-stabilization-of-the-world's-second-largest-economy." - , - kebabCamelCase: - "china'S-Factory-Activity-Expanded-In-March-After-Five-Consecutive-Months-Of-Contraction,An-Official-Survey-Revealed-On-Sunday,Adding-To-A-Run-Of-Indicators-That-Suggest-The-Stabilization-Of-The-World'S-Second-Largest-Economy." - , - kebabPascalCase: - "China'S-Factory-Activity-Expanded-In-March-After-Five-Consecutive-Months-Of-Contraction,An-Official-Survey-Revealed-On-Sunday,Adding-To-A-Run-Of-Indicators-That-Suggest-The-Stabilization-Of-The-World'S-Second-Largest-Economy." - , - kebabUpperCase: - "CHINA'S-FACTORY-ACTIVITY-EXPANDED-IN-MARCH-AFTER-FIVE-CONSECUTIVE-MONTHS-OF-CONTRACTION,AN-OFFICIAL-SURVEY-REVEALED-ON-SUNDAY,ADDING-TO-A-RUN-OF-INDICATORS-THAT-SUGGEST-THE-STABILIZATION-OF-THE-WORLD'S-SECOND-LARGEST-ECONOMY." - , - spaceCase: - "china's factory activity expanded in march after five consecutive months of contraction,an official survey revealed on sunday,adding to a run of indicators that suggest the stabilization of the world's second largest economy." - , - spaceCamelCase: - "china'S Factory Activity Expanded In March After Five Consecutive Months Of Contraction,An Official Survey Revealed On Sunday,Adding To A Run Of Indicators That Suggest The Stabilization Of The World'S Second Largest Economy." - , - spacePascalCase: - "China'S Factory Activity Expanded In March After Five Consecutive Months Of Contraction,An Official Survey Revealed On Sunday,Adding To A Run Of Indicators That Suggest The Stabilization Of The World'S Second Largest Economy." - , - spaceUpperCase: - "CHINA'S FACTORY ACTIVITY EXPANDED IN MARCH AFTER FIVE CONSECUTIVE MONTHS OF CONTRACTION,AN OFFICIAL SURVEY REVEALED ON SUNDAY,ADDING TO A RUN OF INDICATORS THAT SUGGEST THE STABILIZATION OF THE WORLD'S SECOND LARGEST ECONOMY." - , - dotCase: - "china's.factory.activity.expanded.in.march.after.five.consecutive.months.of.contraction,an.official.survey.revealed.on.sunday,adding.to.a.run.of.indicators.that.suggest.the.stabilization.of.the.world's.second.largest.economy." - , - dotCamelCase: - "china'S.Factory.Activity.Expanded.In.March.After.Five.Consecutive.Months.Of.Contraction,An.Official.Survey.Revealed.On.Sunday,Adding.To.A.Run.Of.Indicators.That.Suggest.The.Stabilization.Of.The.World'S.Second.Largest.Economy." - , - dotPascalCase: - "China'S.Factory.Activity.Expanded.In.March.After.Five.Consecutive.Months.Of.Contraction,An.Official.Survey.Revealed.On.Sunday,Adding.To.A.Run.Of.Indicators.That.Suggest.The.Stabilization.Of.The.World'S.Second.Largest.Economy." - , - dotUpperCase: - "CHINA'S.FACTORY.ACTIVITY.EXPANDED.IN.MARCH.AFTER.FIVE.CONSECUTIVE.MONTHS.OF.CONTRACTION,AN.OFFICIAL.SURVEY.REVEALED.ON.SUNDAY,ADDING.TO.A.RUN.OF.INDICATORS.THAT.SUGGEST.THE.STABILIZATION.OF.THE.WORLD'S.SECOND.LARGEST.ECONOMY." - , - lowerCase: - "china's factory activity expanded in march after five consecutive months of contraction, an official survey revealed on sunday, adding to a run of indicators that suggest the stabilization of the world's second-largest economy." - , - upperCase: - "CHINA'S FACTORY ACTIVITY EXPANDED IN MARCH AFTER FIVE CONSECUTIVE MONTHS OF CONTRACTION, AN OFFICIAL SURVEY REVEALED ON SUNDAY, ADDING TO A RUN OF INDICATORS THAT SUGGEST THE STABILIZATION OF THE WORLD'S SECOND-LARGEST ECONOMY." - , - }, - }, - // 输入包含数字 - { - title: 'text and number input', - input: 'entity2Map', - eol: [LF, CRLF], - transformText: [ - 'entity|2|map', - ], - output: { - camelCase: 'entity2Map', - pascalCase: 'Entity2Map', - snakeCase: 'entity2map', - snakeCamelCase: 'entity2Map', - snakePascalCase: 'Entity2Map', - snakeUpperCase: 'ENTITY2MAP', - kebabCase: 'entity2map', - kebabCamelCase: 'entity2Map', - kebabPascalCase: 'Entity2Map', - kebabUpperCase: 'ENTITY2MAP', - spaceCase: 'entity2map', - spaceCamelCase: 'entity2Map', - spacePascalCase: 'Entity2Map', - spaceUpperCase: 'ENTITY2MAP', - dotCase: 'entity2map', - dotCamelCase: 'entity2Map', - dotPascalCase: 'Entity2Map', - dotUpperCase: 'ENTITY2MAP', - lowerCase: 'entity2map', - upperCase: 'ENTITY2MAP', - }, - }, - // 输入包含换行 - { - title: 'enter input', - input: - 'How do you\bdo?\n How do you\tdo!' - , - eol: [LF], - transformText: [ - 'how|do|you|\b|do|?', - ' how|do|you|\t|do|!', - ], - output: { - camelCase: 'howDoYou\bDo?\n howDoYou\tDo!', - pascalCase: 'HowDoYou\bDo?\n HowDoYou\tDo!', - snakeCase: 'how_do_you\bdo?\n how_do_you\tdo!', - snakeCamelCase: 'how_Do_You\bDo?\n how_Do_You\tDo!', - snakePascalCase: 'How_Do_You\bDo?\n How_Do_You\tDo!', - snakeUpperCase: 'HOW_DO_YOU\bDO?\n HOW_DO_YOU\tDO!', - kebabCase: 'how-do-you\bdo?\n how-do-you\tdo!', - kebabCamelCase: 'how-Do-You\bDo?\n how-Do-You\tDo!', - kebabPascalCase: 'How-Do-You\bDo?\n How-Do-You\tDo!', - kebabUpperCase: 'HOW-DO-YOU\bDO?\n HOW-DO-YOU\tDO!', - spaceCase: 'how do you\bdo?\n how do you\tdo!', - spaceCamelCase: 'how Do You\bDo?\n how Do You\tDo!', - spacePascalCase: 'How Do You\bDo?\n How Do You\tDo!', - spaceUpperCase: 'HOW DO YOU\bDO?\n HOW DO YOU\tDO!', - dotCase: 'how.do.you\bdo?\n how.do.you\tdo!', - dotCamelCase: 'how.Do.You\bDo?\n how.Do.You\tDo!', - dotPascalCase: 'How.Do.You\bDo?\n How.Do.You\tDo!', - dotUpperCase: 'HOW.DO.YOU\bDO?\n HOW.DO.YOU\tDO!', - lowerCase: 'how do you\bdo?\n how do you\tdo!', - upperCase: 'HOW DO YOU\bDO?\n HOW DO YOU\tDO!', - }, - }, - // 非英文字符,特殊字符 - { - title: 'Chinese input 1', - input: - '今天是星期日' - , - eol: [LF, CRLF], - transformText: [ - '今天是星期日', - ], - output: { - camelCase: '今天是星期日', - pascalCase: '今天是星期日', - snakeCase: '今天是星期日', - snakeCamelCase: '今天是星期日', - snakePascalCase: '今天是星期日', - snakeUpperCase: '今天是星期日', - kebabCase: '今天是星期日', - kebabCamelCase: '今天是星期日', - kebabPascalCase: '今天是星期日', - kebabUpperCase: '今天是星期日', - spaceCase: '今天是星期日', - spaceCamelCase: '今天是星期日', - spacePascalCase: '今天是星期日', - spaceUpperCase: '今天是星期日', - dotCase: '今天是星期日', - dotCamelCase: '今天是星期日', - dotPascalCase: '今天是星期日', - dotUpperCase: '今天是星期日', - lowerCase: '今天是星期日', - upperCase: '今天是星期日', - }, - }, - { - title: 'Chinese input 2', - input: - '--担心你dAf_=coffee—爸妈不在家_— ' - , - eol: [LF, CRLF], - transformText: [ - '担心你|d|af|=|coffee|—爸妈不在家|— ', - ], - output: { - camelCase: '担心你dAf=Coffee—爸妈不在家— ', - pascalCase: '担心你DAf=Coffee—爸妈不在家— ', - snakeCase: '担心你d_af=coffee—爸妈不在家— ', - snakeCamelCase: '担心你d_Af=Coffee—爸妈不在家— ', - snakePascalCase: '担心你D_Af=Coffee—爸妈不在家— ', - snakeUpperCase: '担心你D_AF=COFFEE—爸妈不在家— ', - kebabCase: '担心你d-af=coffee—爸妈不在家— ', - kebabCamelCase: '担心你d-Af=Coffee—爸妈不在家— ', - kebabPascalCase: '担心你D-Af=Coffee—爸妈不在家— ', - kebabUpperCase: '担心你D-AF=COFFEE—爸妈不在家— ', - spaceCase: '担心你d af=coffee—爸妈不在家— ', - spaceCamelCase: '担心你d Af=Coffee—爸妈不在家— ', - spacePascalCase: '担心你D Af=Coffee—爸妈不在家— ', - spaceUpperCase: '担心你D AF=COFFEE—爸妈不在家— ', - dotCase: '担心你d.af=coffee—爸妈不在家— ', - dotCamelCase: '担心你d.Af=Coffee—爸妈不在家— ', - dotPascalCase: '担心你D.Af=Coffee—爸妈不在家— ', - dotUpperCase: '担心你D.AF=COFFEE—爸妈不在家— ', - lowerCase: '--担心你daf_=coffee—爸妈不在家_— ', - upperCase: '--担心你DAF_=COFFEE—爸妈不在家_— ', - }, - }, - { - title: 'Special character with emoji input', - input: - '🥰 a-cup/_of Coffee🍻,-_please.thanks!. ' - , - eol: [LF, CRLF], - transformText: [ - '🥰|a|cup|/|of|coffee|🍻,|please|.|thanks|!. ', - ], - output: { - camelCase: '🥰aCup/OfCoffee🍻,Please.Thanks!. ', - pascalCase: '🥰ACup/OfCoffee🍻,Please.Thanks!. ', - snakeCase: '🥰a_cup/of_coffee🍻,please.thanks!. ', - snakeCamelCase: '🥰a_Cup/Of_Coffee🍻,Please.Thanks!. ', - snakePascalCase: '🥰A_Cup/Of_Coffee🍻,Please.Thanks!. ', - snakeUpperCase: '🥰A_CUP/OF_COFFEE🍻,PLEASE.THANKS!. ', - kebabCase: '🥰a-cup/of-coffee🍻,please.thanks!. ', - kebabCamelCase: '🥰a-Cup/Of-Coffee🍻,Please.Thanks!. ', - kebabPascalCase: '🥰A-Cup/Of-Coffee🍻,Please.Thanks!. ', - kebabUpperCase: '🥰A-CUP/OF-COFFEE🍻,PLEASE.THANKS!. ', - spaceCase: '🥰a cup/of coffee🍻,please.thanks!. ', - spaceCamelCase: '🥰a Cup/Of Coffee🍻,Please.Thanks!. ', - spacePascalCase: '🥰A Cup/Of Coffee🍻,Please.Thanks!. ', - spaceUpperCase: '🥰A CUP/OF COFFEE🍻,PLEASE.THANKS!. ', - dotCase: '🥰a.cup/of.coffee🍻,please.thanks!. ', - dotCamelCase: '🥰a.Cup/Of.Coffee🍻,Please.Thanks!. ', - dotPascalCase: '🥰A.Cup/Of.Coffee🍻,Please.Thanks!. ', - dotUpperCase: '🥰A.CUP/OF.COFFEE🍻,PLEASE.THANKS!. ', - lowerCase: '🥰 a-cup/_of coffee🍻,-_please.thanks!. ', - upperCase: '🥰 A-CUP/_OF COFFEE🍻,-_PLEASE.THANKS!. ', - }, - }, - { - title: 'Special character with multiple input', - input: - 'takeARest😊haPPy,😢triSTE,ENFADADO, 驚きました,❤️, 笑, 😎COol, 😳-Embarrassed' - , - eol: [LF, CRLF], - transformText: [ - 'take|a|rest|😊|ha|p|py|,😢|tri|ste|,|enfadado|,|驚きました,❤️,|笑,|😎|c|ool|,|😳|embarrassed', - ], - output: { - camelCase: 'takeARest😊HaPPy,😢TriSte,Enfadado,驚きました,❤️,笑,😎COol,😳Embarrassed', - pascalCase: 'TakeARest😊HaPPy,😢TriSte,Enfadado,驚きました,❤️,笑,😎COol,😳Embarrassed', - snakeCase: 'take_a_rest😊ha_p_py,😢tri_ste,enfadado,驚きました,❤️,笑,😎c_ool,😳embarrassed', - snakeCamelCase: 'take_A_Rest😊Ha_P_Py,😢Tri_Ste,Enfadado,驚きました,❤️,笑,😎C_Ool,😳Embarrassed', - snakePascalCase: 'Take_A_Rest😊Ha_P_Py,😢Tri_Ste,Enfadado,驚きました,❤️,笑,😎C_Ool,😳Embarrassed', - snakeUpperCase: 'TAKE_A_REST😊HA_P_PY,😢TRI_STE,ENFADADO,驚きました,❤️,笑,😎C_OOL,😳EMBARRASSED', - kebabCase: 'take-a-rest😊ha-p-py,😢tri-ste,enfadado,驚きました,❤️,笑,😎c-ool,😳embarrassed', - kebabCamelCase: 'take-A-Rest😊Ha-P-Py,😢Tri-Ste,Enfadado,驚きました,❤️,笑,😎C-Ool,😳Embarrassed', - kebabPascalCase: 'Take-A-Rest😊Ha-P-Py,😢Tri-Ste,Enfadado,驚きました,❤️,笑,😎C-Ool,😳Embarrassed', - kebabUpperCase: 'TAKE-A-REST😊HA-P-PY,😢TRI-STE,ENFADADO,驚きました,❤️,笑,😎C-OOL,😳EMBARRASSED', - spaceCase: 'take a rest😊ha p py,😢tri ste,enfadado,驚きました,❤️,笑,😎c ool,😳embarrassed', - spaceCamelCase: 'take A Rest😊Ha P Py,😢Tri Ste,Enfadado,驚きました,❤️,笑,😎C Ool,😳Embarrassed', - spacePascalCase: 'Take A Rest😊Ha P Py,😢Tri Ste,Enfadado,驚きました,❤️,笑,😎C Ool,😳Embarrassed', - spaceUpperCase: 'TAKE A REST😊HA P PY,😢TRI STE,ENFADADO,驚きました,❤️,笑,😎C OOL,😳EMBARRASSED', - dotCase: 'take.a.rest😊ha.p.py,😢tri.ste,enfadado,驚きました,❤️,笑,😎c.ool,😳embarrassed', - dotCamelCase: 'take.A.Rest😊Ha.P.Py,😢Tri.Ste,Enfadado,驚きました,❤️,笑,😎C.Ool,😳Embarrassed', - dotPascalCase: 'Take.A.Rest😊Ha.P.Py,😢Tri.Ste,Enfadado,驚きました,❤️,笑,😎C.Ool,😳Embarrassed', - dotUpperCase: 'TAKE.A.REST😊HA.P.PY,😢TRI.STE,ENFADADO,驚きました,❤️,笑,😎C.OOL,😳EMBARRASSED', - lowerCase: 'takearest😊happy,😢triste,enfadado, 驚きました,❤️, 笑, 😎cool, 😳-embarrassed', - upperCase: 'TAKEAREST😊HAPPY,😢TRISTE,ENFADADO, 驚きました,❤️, 笑, 😎COOL, 😳-EMBARRASSED', - }, - }, - { - title: 'Random input', - input: - ' NHDAs--+90-usz&* ' - , - eol: [LF, CRLF], - transformText: [ - ' n|h|d|as|+90|usz|&* ', - ], - output: { - camelCase: ' nHDAs+90Usz&* ', - pascalCase: ' NHDAs+90Usz&* ', - snakeCase: ' n_h_d_as+90usz&* ', - snakeCamelCase: ' n_H_D_As+90Usz&* ', - snakePascalCase: ' N_H_D_As+90Usz&* ', - snakeUpperCase: ' N_H_D_AS+90USZ&* ', - kebabCase: ' n-h-d-as+90usz&* ', - kebabCamelCase: ' n-H-D-As+90Usz&* ', - kebabPascalCase: ' N-H-D-As+90Usz&* ', - kebabUpperCase: ' N-H-D-AS+90USZ&* ', - spaceCase: ' n h d as+90usz&* ', - spaceCamelCase: ' n H D As+90Usz&* ', - spacePascalCase: ' N H D As+90Usz&* ', - spaceUpperCase: ' N H D AS+90USZ&* ', - dotCase: ' n.h.d.as+90usz&* ', - dotCamelCase: ' n.H.D.As+90Usz&* ', - dotPascalCase: ' N.H.D.As+90Usz&* ', - dotUpperCase: ' N.H.D.AS+90USZ&* ', - lowerCase: ' nhdas--+90-usz&* ', - upperCase: ' NHDAS--+90-USZ&* ', - }, - }, - { - title: 'Mixed input 1', - input: - 'fsdi_sdacsaf+desd' - , - eol: [LF, CRLF], - transformText: [ - 'fsdi|sdacsaf|+|desd', - ], - output: { - camelCase: 'fsdiSdacsaf+Desd', - pascalCase: 'FsdiSdacsaf+Desd', - snakeCase: 'fsdi_sdacsaf+desd', - snakeCamelCase: 'fsdi_Sdacsaf+Desd', - snakePascalCase: 'Fsdi_Sdacsaf+Desd', - snakeUpperCase: 'FSDI_SDACSAF+DESD', - kebabCase: 'fsdi-sdacsaf+desd', - kebabCamelCase: 'fsdi-Sdacsaf+Desd', - kebabPascalCase: 'Fsdi-Sdacsaf+Desd', - kebabUpperCase: 'FSDI-SDACSAF+DESD', - spaceCase: 'fsdi sdacsaf+desd', - spaceCamelCase: 'fsdi Sdacsaf+Desd', - spacePascalCase: 'Fsdi Sdacsaf+Desd', - spaceUpperCase: 'FSDI SDACSAF+DESD', - dotCase: 'fsdi.sdacsaf+desd', - dotCamelCase: 'fsdi.Sdacsaf+Desd', - dotPascalCase: 'Fsdi.Sdacsaf+Desd', - dotUpperCase: 'FSDI.SDACSAF+DESD', - lowerCase: 'fsdi_sdacsaf+desd', - upperCase: 'FSDI_SDACSAF+DESD', - }, - }, - // add more cases... - ], - }, - { - group: 'Functional verification', - testTitle: 'Functional verification (功能验证)', - cases: [ - // 正常输入 - { - title: 'Normal input (foo-bar)', - input: [ - 'foo--bar', - '-foo -bar', - '__foo - _bar-__', - ], - eol: [LF, CRLF], - transformText: [ - 'foo|bar', - ], - output: { - camelCase: 'fooBar', - pascalCase: 'FooBar', - snakeCase: 'foo_bar', - snakeCamelCase: 'foo_Bar', - snakePascalCase: 'Foo_Bar', - snakeUpperCase: 'FOO_BAR', - kebabCase: 'foo-bar', - kebabCamelCase: 'foo-Bar', - kebabPascalCase: 'Foo-Bar', - kebabUpperCase: 'FOO-BAR', - spaceCase: 'foo bar', - spaceCamelCase: 'foo Bar', - spacePascalCase: 'Foo Bar', - spaceUpperCase: 'FOO BAR', - dotCase: 'foo.bar', - dotCamelCase: 'foo.Bar', - dotPascalCase: 'Foo.Bar', - dotUpperCase: 'FOO.BAR', - // lowerCase: 'foo--bar', - // upperCase: 'FOO--BAR', - }, - }, - { - title: 'Normal input (test-case)', - input: [ - 'test case', - 'test_case', - 'test-case', - 'testCase', - 'TestCase', - 'TEST_CASE', - ], - eol: [LF, CRLF], - transformText: [ - 'test|case', - ], - output: { - camelCase: 'testCase', - pascalCase: 'TestCase', - snakeCase: 'test_case', - snakeCamelCase: 'test_Case', - snakePascalCase: 'Test_Case', - snakeUpperCase: 'TEST_CASE', - kebabCase: 'test-case', - kebabCamelCase: 'test-Case', - kebabPascalCase: 'Test-Case', - kebabUpperCase: 'TEST-CASE', - spaceCase: 'test case', - spaceCamelCase: 'test Case', - spacePascalCase: 'Test Case', - spaceUpperCase: 'TEST CASE', - dotCase: 'test.case', - dotCamelCase: 'test.Case', - dotPascalCase: 'Test.Case', - dotUpperCase: 'TEST.CASE', - // lowerCase: 'test case', - // upperCase: 'TEST CASE', - }, - }, - { - title: 'Normal input (apple)', - input: [ - 'apple', - 'APPLE', - 'Apple', - ], - eol: [LF, CRLF], - transformText: [ - 'apple', - ], - output: { - camelCase: 'apple', - pascalCase: 'Apple', - snakeCase: 'apple', - snakeCamelCase: 'apple', - snakePascalCase: 'Apple', - snakeUpperCase: 'APPLE', - kebabCase: 'apple', - kebabCamelCase: 'apple', - kebabPascalCase: 'Apple', - kebabUpperCase: 'APPLE', - spaceCase: 'apple', - spaceCamelCase: 'apple', - spacePascalCase: 'Apple', - spaceUpperCase: 'APPLE', - dotCase: 'apple', - dotCamelCase: 'apple', - dotPascalCase: 'Apple', - dotUpperCase: 'APPLE', - lowerCase: 'apple', - upperCase: 'APPLE', - }, - }, - { - title: 'Normal input (pine-apple)', - input: [ - 'pineApple', - ], - eol: [LF, CRLF], - transformText: [ - 'pine|apple', - ], - output: { - camelCase: 'pineApple', - pascalCase: 'PineApple', - snakeCase: 'pine_apple', - snakeCamelCase: 'pine_Apple', - snakePascalCase: 'Pine_Apple', - snakeUpperCase: 'PINE_APPLE', - kebabCase: 'pine-apple', - kebabCamelCase: 'pine-Apple', - kebabPascalCase: 'Pine-Apple', - kebabUpperCase: 'PINE-APPLE', - spaceCase: 'pine apple', - spaceCamelCase: 'pine Apple', - spacePascalCase: 'Pine Apple', - spaceUpperCase: 'PINE APPLE', - dotCase: 'pine.apple', - dotCamelCase: 'pine.Apple', - dotPascalCase: 'Pine.Apple', - dotUpperCase: 'PINE.APPLE', - lowerCase: 'pineapple', - upperCase: 'PINEAPPLE', - }, - }, - { - title: 'Normal input (have-a-nice-day!)', - input: [ - 'Have a nice day!', - 'have a nice day!', - 'Have-a-nice-day!', - 'have-a-nice-day!', - 'HAVE-A-NICE-DAY!', - 'Have_a_nice_day!', - 'have_a_nice_day!', - 'HAVE_A_NICE_DAY!', - 'HaveANiceDay!', - 'haveANiceDay!', - ], - eol: [LF, CRLF], - transformText: [ - 'have|a|nice|day|!', - ], - output: { - camelCase: 'haveANiceDay!', - pascalCase: 'HaveANiceDay!', - snakeCase: 'have_a_nice_day!', - snakeCamelCase: 'have_A_Nice_Day!', - snakePascalCase: 'Have_A_Nice_Day!', - snakeUpperCase: 'HAVE_A_NICE_DAY!', - kebabCase: 'have-a-nice-day!', - kebabCamelCase: 'have-A-Nice-Day!', - kebabPascalCase: 'Have-A-Nice-Day!', - kebabUpperCase: 'HAVE-A-NICE-DAY!', - spaceCase: 'have a nice day!', - spaceCamelCase: 'have A Nice Day!', - spacePascalCase: 'Have A Nice Day!', - spaceUpperCase: 'HAVE A NICE DAY!', - dotCase: 'have.a.nice.day!', - dotCamelCase: 'have.A.Nice.Day!', - dotPascalCase: 'Have.A.Nice.Day!', - dotUpperCase: 'HAVE.A.NICE.DAY!', - // lowerCase: 'have a nice day!', - // upperCase: 'HAVE A NICE DAY!', - }, - }, - { - title: 'Normal input (Dot input: Every day of your life)', - input: '.Every day of your life.. it is..important..to take.the.time to “smell the roses” — to appreciate the experiences that lead to happiness. This is part of being truly happy.', - eol: [LF, CRLF], - transformText: [ - '.|every|day|of|your|life|..|it|is|..|important|..|to|take|.|the|.|time|to|“|smell|the|roses|”|—|to|appreciate|the|experiences|that|lead|to|happiness|.|this|is|part|of|being|truly|happy|.', - ], - output: { - camelCase: - '.everyDayOfYourLife..ItIs..Important..ToTake.The.TimeTo“SmellTheRoses”—ToAppreciateTheExperiencesThatLeadToHappiness.ThisIsPartOfBeingTrulyHappy.' - , - pascalCase: - '.EveryDayOfYourLife..ItIs..Important..ToTake.The.TimeTo“SmellTheRoses”—ToAppreciateTheExperiencesThatLeadToHappiness.ThisIsPartOfBeingTrulyHappy.' - , - snakeCase: - '.every_day_of_your_life..it_is..important..to_take.the.time_to“smell_the_roses”—to_appreciate_the_experiences_that_lead_to_happiness.this_is_part_of_being_truly_happy.' - , - snakeCamelCase: - '.every_Day_Of_Your_Life..It_Is..Important..To_Take.The.Time_To“Smell_The_Roses”—To_Appreciate_The_Experiences_That_Lead_To_Happiness.This_Is_Part_Of_Being_Truly_Happy.' - , - snakePascalCase: - '.Every_Day_Of_Your_Life..It_Is..Important..To_Take.The.Time_To“Smell_The_Roses”—To_Appreciate_The_Experiences_That_Lead_To_Happiness.This_Is_Part_Of_Being_Truly_Happy.' - , - snakeUpperCase: - '.EVERY_DAY_OF_YOUR_LIFE..IT_IS..IMPORTANT..TO_TAKE.THE.TIME_TO“SMELL_THE_ROSES”—TO_APPRECIATE_THE_EXPERIENCES_THAT_LEAD_TO_HAPPINESS.THIS_IS_PART_OF_BEING_TRULY_HAPPY.' - , - kebabCase: - '.every-day-of-your-life..it-is..important..to-take.the.time-to“smell-the-roses”—to-appreciate-the-experiences-that-lead-to-happiness.this-is-part-of-being-truly-happy.' - , - kebabCamelCase: - '.every-Day-Of-Your-Life..It-Is..Important..To-Take.The.Time-To“Smell-The-Roses”—To-Appreciate-The-Experiences-That-Lead-To-Happiness.This-Is-Part-Of-Being-Truly-Happy.' - , - kebabPascalCase: - '.Every-Day-Of-Your-Life..It-Is..Important..To-Take.The.Time-To“Smell-The-Roses”—To-Appreciate-The-Experiences-That-Lead-To-Happiness.This-Is-Part-Of-Being-Truly-Happy.' - , - kebabUpperCase: - '.EVERY-DAY-OF-YOUR-LIFE..IT-IS..IMPORTANT..TO-TAKE.THE.TIME-TO“SMELL-THE-ROSES”—TO-APPRECIATE-THE-EXPERIENCES-THAT-LEAD-TO-HAPPINESS.THIS-IS-PART-OF-BEING-TRULY-HAPPY.' - , - spaceCase: - '.every day of your life..it is..important..to take.the.time to“smell the roses”—to appreciate the experiences that lead to happiness.this is part of being truly happy.' - , - spaceCamelCase: - '.every Day Of Your Life..It Is..Important..To Take.The.Time To“Smell The Roses”—To Appreciate The Experiences That Lead To Happiness.This Is Part Of Being Truly Happy.' - , - spacePascalCase: - '.Every Day Of Your Life..It Is..Important..To Take.The.Time To“Smell The Roses”—To Appreciate The Experiences That Lead To Happiness.This Is Part Of Being Truly Happy.' - , - spaceUpperCase: - '.EVERY DAY OF YOUR LIFE..IT IS..IMPORTANT..TO TAKE.THE.TIME TO“SMELL THE ROSES”—TO APPRECIATE THE EXPERIENCES THAT LEAD TO HAPPINESS.THIS IS PART OF BEING TRULY HAPPY.' - , - dotCase: - '.every.day.of.your.life..it.is..important..to.take.the.time.to“smell.the.roses”—to.appreciate.the.experiences.that.lead.to.happiness.this.is.part.of.being.truly.happy.' - , - dotCamelCase: - '.every.Day.Of.Your.Life..It.Is..Important..To.Take.The.Time.To“Smell.The.Roses”—To.Appreciate.The.Experiences.That.Lead.To.Happiness.This.Is.Part.Of.Being.Truly.Happy.' - , - dotPascalCase: - '.Every.Day.Of.Your.Life..It.Is..Important..To.Take.The.Time.To“Smell.The.Roses”—To.Appreciate.The.Experiences.That.Lead.To.Happiness.This.Is.Part.Of.Being.Truly.Happy.' - , - dotUpperCase: - '.EVERY.DAY.OF.YOUR.LIFE..IT.IS..IMPORTANT..TO.TAKE.THE.TIME.TO“SMELL.THE.ROSES”—TO.APPRECIATE.THE.EXPERIENCES.THAT.LEAD.TO.HAPPINESS.THIS.IS.PART.OF.BEING.TRULY.HAPPY.' - , - lowerCase: - '.every day of your life.. it is..important..to take.the.time to “smell the roses” — to appreciate the experiences that lead to happiness. this is part of being truly happy.' - , - upperCase: - '.EVERY DAY OF YOUR LIFE.. IT IS..IMPORTANT..TO TAKE.THE.TIME TO “SMELL THE ROSES” — TO APPRECIATE THE EXPERIENCES THAT LEAD TO HAPPINESS. THIS IS PART OF BEING TRULY HAPPY.' - , - }, - }, - { - title: 'Normal input (a-nice-day!)', - input: [ - ' A nice day! ', - ' a_nice_day! ', - ' ANiceDay! ', - ' A_NICE_DAY! ', - // ' A_Nice_DaY! ', - // ' A-NiCe_Day! ', - // ' A----NiCe_Day_-_!-- ', - ' A----NICE_Day_-_!-- ', - ], - eol: [LF, CRLF], - transformText: [ - ' a|nice|day|! ', - ], - output: { - camelCase: ' aNiceDay! ', - pascalCase: ' ANiceDay! ', - snakeCase: ' a_nice_day! ', - snakeCamelCase: ' a_Nice_Day! ', - snakePascalCase: ' A_Nice_Day! ', - snakeUpperCase: ' A_NICE_DAY! ', - kebabCase: ' a-nice-day! ', - kebabCamelCase: ' a-Nice-Day! ', - kebabPascalCase: ' A-Nice-Day! ', - kebabUpperCase: ' A-NICE-DAY! ', - spaceCase: ' a nice day! ', - spaceCamelCase: ' a Nice Day! ', - spacePascalCase: ' A Nice Day! ', - spaceUpperCase: ' A NICE DAY! ', - dotCase: ' a.nice.day! ', - dotCamelCase: ' a.Nice.Day! ', - dotPascalCase: ' A.Nice.Day! ', - dotUpperCase: ' A.NICE.DAY! ', - // lowerCase: ' a nice day! ', - // upperCase: ' A NICE DAY! ', - }, - }, - { - title: 'Normal input (a-nice-day)', - input: [ - ' A NICE-Day-', - ' A niceDay', - ], - eol: [LF, CRLF], - transformText: [ - ' a|nice|day', - ], - output: { - camelCase: ' aNiceDay', - pascalCase: ' ANiceDay', - snakeCase: ' a_nice_day', - snakeCamelCase: ' a_Nice_Day', - snakePascalCase: ' A_Nice_Day', - snakeUpperCase: ' A_NICE_DAY', - kebabCase: ' a-nice-day', - kebabCamelCase: ' a-Nice-Day', - kebabPascalCase: ' A-Nice-Day', - kebabUpperCase: ' A-NICE-DAY', - spaceCase: ' a nice day', - spaceCamelCase: ' a Nice Day', - spacePascalCase: ' A Nice Day', - spaceUpperCase: ' A NICE DAY', - dotCase: ' a.nice.day', - dotCamelCase: ' a.Nice.Day', - dotPascalCase: ' A.Nice.Day', - dotUpperCase: ' A.NICE.DAY', - // lowerCase: ' a nice-day-', - // upperCase: ' A NICE-DAY-', - }, - }, - { - title: 'Normal input (tom-likes-eat-ice-cream)', - input: [ - 'TomLikes eat iceCream.', - ], - eol: [LF, CRLF], - transformText: [ - 'tom|likes|eat|ice|cream|.', - ], - output: { - camelCase: 'tomLikesEatIceCream.', - pascalCase: 'TomLikesEatIceCream.', - snakeCase: 'tom_likes_eat_ice_cream.', - snakeCamelCase: 'tom_Likes_Eat_Ice_Cream.', - snakePascalCase: 'Tom_Likes_Eat_Ice_Cream.', - snakeUpperCase: 'TOM_LIKES_EAT_ICE_CREAM.', - kebabCase: 'tom-likes-eat-ice-cream.', - kebabCamelCase: 'tom-Likes-Eat-Ice-Cream.', - kebabPascalCase: 'Tom-Likes-Eat-Ice-Cream.', - kebabUpperCase: 'TOM-LIKES-EAT-ICE-CREAM.', - spaceCase: 'tom likes eat ice cream.', - spaceCamelCase: 'tom Likes Eat Ice Cream.', - spacePascalCase: 'Tom Likes Eat Ice Cream.', - spaceUpperCase: 'TOM LIKES EAT ICE CREAM.', - dotCase: 'tom.likes.eat.ice.cream.', - dotCamelCase: 'tom.Likes.Eat.Ice.Cream.', - dotPascalCase: 'Tom.Likes.Eat.Ice.Cream.', - dotUpperCase: 'TOM.LIKES.EAT.ICE.CREAM.', - lowerCase: 'tomlikes eat icecream.', - upperCase: 'TOMLIKES EAT ICECREAM.', - }, - }, - { - title: 'Normal input (apple-2-Tree)', - input: [ - ' apple2-Tree ', - ' apple2Tree ', - ], - eol: [LF, CRLF], - transformText: [ - ' apple|2|tree ', - ], - output: { - camelCase: ' apple2Tree ', - pascalCase: ' Apple2Tree ', - snakeCase: ' apple2tree ', - snakeCamelCase: ' apple2Tree ', - snakePascalCase: ' Apple2Tree ', - snakeUpperCase: ' APPLE2TREE ', - kebabCase: ' apple2tree ', - kebabCamelCase: ' apple2Tree ', - kebabPascalCase: ' Apple2Tree ', - kebabUpperCase: ' APPLE2TREE ', - spaceCase: ' apple2tree ', - spaceCamelCase: ' apple2Tree ', - spacePascalCase: ' Apple2Tree ', - spaceUpperCase: ' APPLE2TREE ', - dotCase: ' apple2tree ', - dotCamelCase: ' apple2Tree ', - dotPascalCase: ' Apple2Tree ', - dotUpperCase: ' APPLE2TREE ', - // lowerCase: ' apple2-tree ', - // upperCase: ' APPLE2-TREE ', - }, - }, - { - title: 'Normal input (Julius-Caesar, William-Shakespeare, ...)', - input: - ' Julius_Caesar, William_Shakespeare, Albert_Einstein, Marie_Curie, WolfgangAmadeusMozart, Vincent-van-Gogh. ' - , - eol: [LF, CRLF], - transformText: [ - ' julius|caesar|,|william|shakespeare|,|albert|einstein|,|marie|curie|,|wolfgang|amadeus|mozart|,|vincent|van|gogh|. ', - ], - output: { - camelCase: ' juliusCaesar,WilliamShakespeare,AlbertEinstein,MarieCurie,WolfgangAmadeusMozart,VincentVanGogh. ', - pascalCase: ' JuliusCaesar,WilliamShakespeare,AlbertEinstein,MarieCurie,WolfgangAmadeusMozart,VincentVanGogh. ', - snakeCase: ' julius_caesar,william_shakespeare,albert_einstein,marie_curie,wolfgang_amadeus_mozart,vincent_van_gogh. ', - snakeCamelCase: ' julius_Caesar,William_Shakespeare,Albert_Einstein,Marie_Curie,Wolfgang_Amadeus_Mozart,Vincent_Van_Gogh. ', - snakePascalCase: ' Julius_Caesar,William_Shakespeare,Albert_Einstein,Marie_Curie,Wolfgang_Amadeus_Mozart,Vincent_Van_Gogh. ', - snakeUpperCase: ' JULIUS_CAESAR,WILLIAM_SHAKESPEARE,ALBERT_EINSTEIN,MARIE_CURIE,WOLFGANG_AMADEUS_MOZART,VINCENT_VAN_GOGH. ', - kebabCase: ' julius-caesar,william-shakespeare,albert-einstein,marie-curie,wolfgang-amadeus-mozart,vincent-van-gogh. ', - kebabCamelCase: ' julius-Caesar,William-Shakespeare,Albert-Einstein,Marie-Curie,Wolfgang-Amadeus-Mozart,Vincent-Van-Gogh. ', - kebabPascalCase: ' Julius-Caesar,William-Shakespeare,Albert-Einstein,Marie-Curie,Wolfgang-Amadeus-Mozart,Vincent-Van-Gogh. ', - kebabUpperCase: ' JULIUS-CAESAR,WILLIAM-SHAKESPEARE,ALBERT-EINSTEIN,MARIE-CURIE,WOLFGANG-AMADEUS-MOZART,VINCENT-VAN-GOGH. ', - spaceCase: ' julius caesar,william shakespeare,albert einstein,marie curie,wolfgang amadeus mozart,vincent van gogh. ', - spaceCamelCase: ' julius Caesar,William Shakespeare,Albert Einstein,Marie Curie,Wolfgang Amadeus Mozart,Vincent Van Gogh. ', - spacePascalCase: ' Julius Caesar,William Shakespeare,Albert Einstein,Marie Curie,Wolfgang Amadeus Mozart,Vincent Van Gogh. ', - spaceUpperCase: ' JULIUS CAESAR,WILLIAM SHAKESPEARE,ALBERT EINSTEIN,MARIE CURIE,WOLFGANG AMADEUS MOZART,VINCENT VAN GOGH. ', - dotCase: ' julius.caesar,william.shakespeare,albert.einstein,marie.curie,wolfgang.amadeus.mozart,vincent.van.gogh. ', - dotCamelCase: ' julius.Caesar,William.Shakespeare,Albert.Einstein,Marie.Curie,Wolfgang.Amadeus.Mozart,Vincent.Van.Gogh. ', - dotPascalCase: ' Julius.Caesar,William.Shakespeare,Albert.Einstein,Marie.Curie,Wolfgang.Amadeus.Mozart,Vincent.Van.Gogh. ', - dotUpperCase: ' JULIUS.CAESAR,WILLIAM.SHAKESPEARE,ALBERT.EINSTEIN,MARIE.CURIE,WOLFGANG.AMADEUS.MOZART,VINCENT.VAN.GOGH. ', - lowerCase: ' julius_caesar, william_shakespeare, albert_einstein, marie_curie, wolfgangamadeusmozart, vincent-van-gogh. ', - upperCase: ' JULIUS_CAESAR, WILLIAM_SHAKESPEARE, ALBERT_EINSTEIN, MARIE_CURIE, WOLFGANGAMADEUSMOZART, VINCENT-VAN-GOGH. ', - }, - }, - { - title: 'Normal input ("You" (or "Your") ...)', - input: - ' "You" (or "Your") shall mean an individual or Legal Entity\n' + - ' exercising permissions granted by this License.' - , - eol: [LF], - transformText: [ - ' &|quot|;|you|&|quot|;|(|or|&|quot|;|your|&|quot|;)|shall|mean|an|individual|or|legal|entity', - ' exercising|permissions|granted|by|this|license|.', - ], - output: { - camelCase: - ' "You&Quot;(Or&Quot;Your&Quot;)ShallMeanAnIndividualOrLegalEntity\n' + - ' exercisingPermissionsGrantedByThisLicense.' - , - pascalCase: - ' &Quot;You&Quot;(Or&Quot;Your&Quot;)ShallMeanAnIndividualOrLegalEntity\n' + - ' ExercisingPermissionsGrantedByThisLicense.' - , - snakeCase: - ' "you"(or"your")shall_mean_an_individual_or_legal_entity\n' + - ' exercising_permissions_granted_by_this_license.' - , - snakeCamelCase: - ' "You&Quot;(Or&Quot;Your&Quot;)Shall_Mean_An_Individual_Or_Legal_Entity\n' + - ' exercising_Permissions_Granted_By_This_License.' - , - snakePascalCase: - ' &Quot;You&Quot;(Or&Quot;Your&Quot;)Shall_Mean_An_Individual_Or_Legal_Entity\n' + - ' Exercising_Permissions_Granted_By_This_License.' - , - snakeUpperCase: - ' "YOU"(OR"YOUR")SHALL_MEAN_AN_INDIVIDUAL_OR_LEGAL_ENTITY\n' + - ' EXERCISING_PERMISSIONS_GRANTED_BY_THIS_LICENSE.' - , - kebabCase: - ' "you"(or"your")shall-mean-an-individual-or-legal-entity\n' + - ' exercising-permissions-granted-by-this-license.' - , - kebabCamelCase: - ' "You&Quot;(Or&Quot;Your&Quot;)Shall-Mean-An-Individual-Or-Legal-Entity\n' + - ' exercising-Permissions-Granted-By-This-License.' - , - kebabPascalCase: - ' &Quot;You&Quot;(Or&Quot;Your&Quot;)Shall-Mean-An-Individual-Or-Legal-Entity\n' + - ' Exercising-Permissions-Granted-By-This-License.' - , - kebabUpperCase: - ' "YOU"(OR"YOUR")SHALL-MEAN-AN-INDIVIDUAL-OR-LEGAL-ENTITY\n' + - ' EXERCISING-PERMISSIONS-GRANTED-BY-THIS-LICENSE.' - , - spaceCase: - ' "you"(or"your")shall mean an individual or legal entity\n' + - ' exercising permissions granted by this license.' - , - spaceCamelCase: - ' "You&Quot;(Or&Quot;Your&Quot;)Shall Mean An Individual Or Legal Entity\n' + - ' exercising Permissions Granted By This License.' - , - spacePascalCase: - ' &Quot;You&Quot;(Or&Quot;Your&Quot;)Shall Mean An Individual Or Legal Entity\n' + - ' Exercising Permissions Granted By This License.' - , - spaceUpperCase: - ' "YOU"(OR"YOUR")SHALL MEAN AN INDIVIDUAL OR LEGAL ENTITY\n' + - ' EXERCISING PERMISSIONS GRANTED BY THIS LICENSE.' - , - dotCase: - ' "you"(or"your")shall.mean.an.individual.or.legal.entity\n' + - ' exercising.permissions.granted.by.this.license.' - , - dotCamelCase: - ' "You&Quot;(Or&Quot;Your&Quot;)Shall.Mean.An.Individual.Or.Legal.Entity\n' + - ' exercising.Permissions.Granted.By.This.License.' - , - dotPascalCase: - ' &Quot;You&Quot;(Or&Quot;Your&Quot;)Shall.Mean.An.Individual.Or.Legal.Entity\n' + - ' Exercising.Permissions.Granted.By.This.License.' - , - dotUpperCase: - ' "YOU"(OR"YOUR")SHALL.MEAN.AN.INDIVIDUAL.OR.LEGAL.ENTITY\n' + - ' EXERCISING.PERMISSIONS.GRANTED.BY.THIS.LICENSE.' - , - lowerCase: - ' "you" (or "your") shall mean an individual or legal entity\n' + - ' exercising permissions granted by this license.' - , - upperCase: - ' "YOU" (OR "YOUR") SHALL MEAN AN INDIVIDUAL OR LEGAL ENTITY\n' + - ' EXERCISING PERMISSIONS GRANTED BY THIS LICENSE.' - , - }, - }, - // add more cases... - ], - }, - { - group: 'Extreme case verification', - testTitle: 'Extreme case verification (极端情况验证)', - cases: [ - // 极端情况 - - // add more cases... - ], - }, - { - group: 'Xxxx verification', - testTitle: 'Xxxx verification (xxx验证)', - cases: [ - // Description - // { - // title: 'Normal input ( ...)', - // input: '', - // eol: [LF, CRLF], - // transformText: [ - // '', - // ], - // output: { - // camelCase: '', - // pascalCase: '', - // snakeCase: '', - // snakeCamelCase: '', - // snakePascalCase: '', - // snakeUpperCase: '', - // kebabCase: '', - // kebabCamelCase: '', - // kebabPascalCase: '', - // kebabUpperCase: '', - // spaceCase: '', - // spaceCamelCase: '', - // spacePascalCase: '', - // spaceUpperCase: '', - // dotCase: '', - // dotCamelCase: '', - // dotPascalCase: '', - // dotUpperCase: '', - // lowerCase: '', - // upperCase: '', - // }, - // }, - // add more cases... - ], - }, - // add more cases... -]; - -export default testGroups; \ No newline at end of file +import { VariableTestCaseGroup } from "./types/VariableTestCaseType"; + +const LF = '\n'; +const CRLF = '\r\n'; + +export const variableConvertTestGroups: Array = [ + { + group: 'Input validation', + testTitle: 'Input validation (输入有效性验证)', + cases: [ + // 输入为空 + { + title: 'empty input', + input: '', + eol: [LF, CRLF], + transformText: [ + '', + ], + output: { + camelCase: '', + pascalCase: '', + snakeCase: '', + snakeCamelCase: '', + snakePascalCase: '', + snakeUpperCase: '', + kebabCase: '', + kebabCamelCase: '', + kebabPascalCase: '', + kebabUpperCase: '', + spaceCase: '', + spaceCamelCase: '', + spacePascalCase: '', + spaceUpperCase: '', + dotCase: '', + dotCamelCase: '', + dotPascalCase: '', + dotUpperCase: '', + lowerCase: '', + upperCase: '', + }, + }, + { + title: 'empty input (contains space)', + input: ' ', + eol: [LF, CRLF], + transformText: [ + ' ', + ], + output: { + camelCase: ' ', + pascalCase: ' ', + snakeCase: ' ', + snakeCamelCase: ' ', + snakePascalCase: ' ', + snakeUpperCase: ' ', + kebabCase: ' ', + kebabCamelCase: ' ', + kebabPascalCase: ' ', + kebabUpperCase: ' ', + spaceCase: ' ', + spaceCamelCase: ' ', + spacePascalCase: ' ', + spaceUpperCase: ' ', + dotCase: ' ', + dotCamelCase: ' ', + dotPascalCase: ' ', + dotUpperCase: ' ', + lowerCase: ' ', + upperCase: ' ', + }, + }, + { + title: 'empty input (contains space and crlf enter 1)', + input: ' \r\n ', + eol: [CRLF], + transformText: [ + ' ', + ' ', + ], + output: { + camelCase: ' \r\n ', + pascalCase: ' \r\n ', + snakeCase: ' \r\n ', + snakeCamelCase: ' \r\n ', + snakePascalCase: ' \r\n ', + snakeUpperCase: ' \r\n ', + kebabCase: ' \r\n ', + kebabCamelCase: ' \r\n ', + kebabPascalCase: ' \r\n ', + kebabUpperCase: ' \r\n ', + spaceCase: ' \r\n ', + spaceCamelCase: ' \r\n ', + spacePascalCase: ' \r\n ', + spaceUpperCase: ' \r\n ', + dotCase: ' \r\n ', + dotCamelCase: ' \r\n ', + dotPascalCase: ' \r\n ', + dotUpperCase: ' \r\n ', + lowerCase: ' \r\n ', + upperCase: ' \r\n ', + }, + }, + { + title: 'empty input (contains space and crlf enter 2)', + input: ' x \r\ny ', + eol: [CRLF], + transformText: [ + ' x ', + 'y ', + ], + output: { + camelCase: ' x \r\ny ', + pascalCase: ' X \r\nY ', + snakeCase: ' x \r\ny ', + snakeCamelCase: ' x \r\ny ', + snakePascalCase: ' X \r\nY ', + snakeUpperCase: ' X \r\nY ', + kebabCase: ' x \r\ny ', + kebabCamelCase: ' x \r\ny ', + kebabPascalCase: ' X \r\nY ', + kebabUpperCase: ' X \r\nY ', + spaceCase: ' x \r\ny ', + spaceCamelCase: ' x \r\ny ', + spacePascalCase: ' X \r\nY ', + spaceUpperCase: ' X \r\nY ', + dotCase: ' x \r\ny ', + dotCamelCase: ' x \r\ny ', + dotPascalCase: ' X \r\nY ', + dotUpperCase: ' X \r\nY ', + lowerCase: ' x \r\ny ', + upperCase: ' X \r\nY ', + }, + }, + { + title: 'empty input (contains space and lf enter 1)', + input: ' \n ', + eol: [LF], + transformText: [ + ' ', + ' ', + ], + output: { + camelCase: ' \n ', + pascalCase: ' \n ', + snakeCase: ' \n ', + snakeCamelCase: ' \n ', + snakePascalCase: ' \n ', + snakeUpperCase: ' \n ', + kebabCase: ' \n ', + kebabCamelCase: ' \n ', + kebabPascalCase: ' \n ', + kebabUpperCase: ' \n ', + spaceCase: ' \n ', + spaceCamelCase: ' \n ', + spacePascalCase: ' \n ', + spaceUpperCase: ' \n ', + dotCase: ' \n ', + dotCamelCase: ' \n ', + dotPascalCase: ' \n ', + dotUpperCase: ' \n ', + lowerCase: ' \n ', + upperCase: ' \n ', + }, + }, + { + title: 'empty input (contains space and lf enter 2)', + input: ' a\nb ', + eol: [LF], + transformText: [ + ' a', + 'b ', + ], + output: { + camelCase: ' a\nb ', + pascalCase: ' A\nB ', + snakeCase: ' a\nb ', + snakeCamelCase: ' a\nb ', + snakePascalCase: ' A\nB ', + snakeUpperCase: ' A\nB ', + kebabCase: ' a\nb ', + kebabCamelCase: ' a\nb ', + kebabPascalCase: ' A\nB ', + kebabUpperCase: ' A\nB ', + spaceCase: ' a\nb ', + spaceCamelCase: ' a\nb ', + spacePascalCase: ' A\nB ', + spaceUpperCase: ' A\nB ', + dotCase: ' a\nb ', + dotCamelCase: ' a\nb ', + dotPascalCase: ' A\nB ', + dotUpperCase: ' A\nB ', + lowerCase: ' a\nb ', + upperCase: ' A\nB ', + }, + }, + // 输入长文本 + { + title: 'long text input', + input: + `China's factory activity expanded in March after five consecutive months of contraction, an official survey revealed on Sunday, adding to a run of indicators that suggest the stabilization of the world's second-largest economy.` + , + eol: [LF, CRLF], + transformText: [ + "china|'|s|factory|activity|expanded|in|march|after|five|consecutive|months|of|contraction|,|an|official|survey|revealed|on|sunday|,|adding|to|a|run|of|indicators|that|suggest|the|stabilization|of|the|world|'|s|second|largest|economy|." + ], + output: { + camelCase: + "china'SFactoryActivityExpandedInMarchAfterFiveConsecutiveMonthsOfContraction,AnOfficialSurveyRevealedOnSunday,AddingToARunOfIndicatorsThatSuggestTheStabilizationOfTheWorld'SSecondLargestEconomy." + , + pascalCase: + "China'SFactoryActivityExpandedInMarchAfterFiveConsecutiveMonthsOfContraction,AnOfficialSurveyRevealedOnSunday,AddingToARunOfIndicatorsThatSuggestTheStabilizationOfTheWorld'SSecondLargestEconomy." + , + snakeCase: + "china's_factory_activity_expanded_in_march_after_five_consecutive_months_of_contraction,an_official_survey_revealed_on_sunday,adding_to_a_run_of_indicators_that_suggest_the_stabilization_of_the_world's_second_largest_economy." + , + snakeCamelCase: + "china'S_Factory_Activity_Expanded_In_March_After_Five_Consecutive_Months_Of_Contraction,An_Official_Survey_Revealed_On_Sunday,Adding_To_A_Run_Of_Indicators_That_Suggest_The_Stabilization_Of_The_World'S_Second_Largest_Economy." + , + snakePascalCase: + "China'S_Factory_Activity_Expanded_In_March_After_Five_Consecutive_Months_Of_Contraction,An_Official_Survey_Revealed_On_Sunday,Adding_To_A_Run_Of_Indicators_That_Suggest_The_Stabilization_Of_The_World'S_Second_Largest_Economy." + , + snakeUpperCase: + "CHINA'S_FACTORY_ACTIVITY_EXPANDED_IN_MARCH_AFTER_FIVE_CONSECUTIVE_MONTHS_OF_CONTRACTION,AN_OFFICIAL_SURVEY_REVEALED_ON_SUNDAY,ADDING_TO_A_RUN_OF_INDICATORS_THAT_SUGGEST_THE_STABILIZATION_OF_THE_WORLD'S_SECOND_LARGEST_ECONOMY." + , + kebabCase: + "china's-factory-activity-expanded-in-march-after-five-consecutive-months-of-contraction,an-official-survey-revealed-on-sunday,adding-to-a-run-of-indicators-that-suggest-the-stabilization-of-the-world's-second-largest-economy." + , + kebabCamelCase: + "china'S-Factory-Activity-Expanded-In-March-After-Five-Consecutive-Months-Of-Contraction,An-Official-Survey-Revealed-On-Sunday,Adding-To-A-Run-Of-Indicators-That-Suggest-The-Stabilization-Of-The-World'S-Second-Largest-Economy." + , + kebabPascalCase: + "China'S-Factory-Activity-Expanded-In-March-After-Five-Consecutive-Months-Of-Contraction,An-Official-Survey-Revealed-On-Sunday,Adding-To-A-Run-Of-Indicators-That-Suggest-The-Stabilization-Of-The-World'S-Second-Largest-Economy." + , + kebabUpperCase: + "CHINA'S-FACTORY-ACTIVITY-EXPANDED-IN-MARCH-AFTER-FIVE-CONSECUTIVE-MONTHS-OF-CONTRACTION,AN-OFFICIAL-SURVEY-REVEALED-ON-SUNDAY,ADDING-TO-A-RUN-OF-INDICATORS-THAT-SUGGEST-THE-STABILIZATION-OF-THE-WORLD'S-SECOND-LARGEST-ECONOMY." + , + spaceCase: + "china's factory activity expanded in march after five consecutive months of contraction,an official survey revealed on sunday,adding to a run of indicators that suggest the stabilization of the world's second largest economy." + , + spaceCamelCase: + "china'S Factory Activity Expanded In March After Five Consecutive Months Of Contraction,An Official Survey Revealed On Sunday,Adding To A Run Of Indicators That Suggest The Stabilization Of The World'S Second Largest Economy." + , + spacePascalCase: + "China'S Factory Activity Expanded In March After Five Consecutive Months Of Contraction,An Official Survey Revealed On Sunday,Adding To A Run Of Indicators That Suggest The Stabilization Of The World'S Second Largest Economy." + , + spaceUpperCase: + "CHINA'S FACTORY ACTIVITY EXPANDED IN MARCH AFTER FIVE CONSECUTIVE MONTHS OF CONTRACTION,AN OFFICIAL SURVEY REVEALED ON SUNDAY,ADDING TO A RUN OF INDICATORS THAT SUGGEST THE STABILIZATION OF THE WORLD'S SECOND LARGEST ECONOMY." + , + dotCase: + "china's.factory.activity.expanded.in.march.after.five.consecutive.months.of.contraction,an.official.survey.revealed.on.sunday,adding.to.a.run.of.indicators.that.suggest.the.stabilization.of.the.world's.second.largest.economy." + , + dotCamelCase: + "china'S.Factory.Activity.Expanded.In.March.After.Five.Consecutive.Months.Of.Contraction,An.Official.Survey.Revealed.On.Sunday,Adding.To.A.Run.Of.Indicators.That.Suggest.The.Stabilization.Of.The.World'S.Second.Largest.Economy." + , + dotPascalCase: + "China'S.Factory.Activity.Expanded.In.March.After.Five.Consecutive.Months.Of.Contraction,An.Official.Survey.Revealed.On.Sunday,Adding.To.A.Run.Of.Indicators.That.Suggest.The.Stabilization.Of.The.World'S.Second.Largest.Economy." + , + dotUpperCase: + "CHINA'S.FACTORY.ACTIVITY.EXPANDED.IN.MARCH.AFTER.FIVE.CONSECUTIVE.MONTHS.OF.CONTRACTION,AN.OFFICIAL.SURVEY.REVEALED.ON.SUNDAY,ADDING.TO.A.RUN.OF.INDICATORS.THAT.SUGGEST.THE.STABILIZATION.OF.THE.WORLD'S.SECOND.LARGEST.ECONOMY." + , + lowerCase: + "china's factory activity expanded in march after five consecutive months of contraction, an official survey revealed on sunday, adding to a run of indicators that suggest the stabilization of the world's second-largest economy." + , + upperCase: + "CHINA'S FACTORY ACTIVITY EXPANDED IN MARCH AFTER FIVE CONSECUTIVE MONTHS OF CONTRACTION, AN OFFICIAL SURVEY REVEALED ON SUNDAY, ADDING TO A RUN OF INDICATORS THAT SUGGEST THE STABILIZATION OF THE WORLD'S SECOND-LARGEST ECONOMY." + , + }, + }, + // 输入包含数字 + { + title: 'text and number input', + input: 'entity2Map', + eol: [LF, CRLF], + transformText: [ + 'entity|2|map', + ], + output: { + camelCase: 'entity2Map', + pascalCase: 'Entity2Map', + snakeCase: 'entity2map', + snakeCamelCase: 'entity2Map', + snakePascalCase: 'Entity2Map', + snakeUpperCase: 'ENTITY2MAP', + kebabCase: 'entity2map', + kebabCamelCase: 'entity2Map', + kebabPascalCase: 'Entity2Map', + kebabUpperCase: 'ENTITY2MAP', + spaceCase: 'entity2map', + spaceCamelCase: 'entity2Map', + spacePascalCase: 'Entity2Map', + spaceUpperCase: 'ENTITY2MAP', + dotCase: 'entity2map', + dotCamelCase: 'entity2Map', + dotPascalCase: 'Entity2Map', + dotUpperCase: 'ENTITY2MAP', + lowerCase: 'entity2map', + upperCase: 'ENTITY2MAP', + }, + }, + // 输入包含换行 + { + title: 'enter input', + input: + 'How do you\bdo?\n How do you\tdo!' + , + eol: [LF], + transformText: [ + 'how|do|you|\b|do|?', + ' how|do|you|\t|do|!', + ], + output: { + camelCase: 'howDoYou\bDo?\n howDoYou\tDo!', + pascalCase: 'HowDoYou\bDo?\n HowDoYou\tDo!', + snakeCase: 'how_do_you\bdo?\n how_do_you\tdo!', + snakeCamelCase: 'how_Do_You\bDo?\n how_Do_You\tDo!', + snakePascalCase: 'How_Do_You\bDo?\n How_Do_You\tDo!', + snakeUpperCase: 'HOW_DO_YOU\bDO?\n HOW_DO_YOU\tDO!', + kebabCase: 'how-do-you\bdo?\n how-do-you\tdo!', + kebabCamelCase: 'how-Do-You\bDo?\n how-Do-You\tDo!', + kebabPascalCase: 'How-Do-You\bDo?\n How-Do-You\tDo!', + kebabUpperCase: 'HOW-DO-YOU\bDO?\n HOW-DO-YOU\tDO!', + spaceCase: 'how do you\bdo?\n how do you\tdo!', + spaceCamelCase: 'how Do You\bDo?\n how Do You\tDo!', + spacePascalCase: 'How Do You\bDo?\n How Do You\tDo!', + spaceUpperCase: 'HOW DO YOU\bDO?\n HOW DO YOU\tDO!', + dotCase: 'how.do.you\bdo?\n how.do.you\tdo!', + dotCamelCase: 'how.Do.You\bDo?\n how.Do.You\tDo!', + dotPascalCase: 'How.Do.You\bDo?\n How.Do.You\tDo!', + dotUpperCase: 'HOW.DO.YOU\bDO?\n HOW.DO.YOU\tDO!', + lowerCase: 'how do you\bdo?\n how do you\tdo!', + upperCase: 'HOW DO YOU\bDO?\n HOW DO YOU\tDO!', + }, + }, + // 非英文字符,特殊字符 + { + title: 'Chinese input 1', + input: + '今天是星期日' + , + eol: [LF, CRLF], + transformText: [ + '今天是星期日', + ], + output: { + camelCase: '今天是星期日', + pascalCase: '今天是星期日', + snakeCase: '今天是星期日', + snakeCamelCase: '今天是星期日', + snakePascalCase: '今天是星期日', + snakeUpperCase: '今天是星期日', + kebabCase: '今天是星期日', + kebabCamelCase: '今天是星期日', + kebabPascalCase: '今天是星期日', + kebabUpperCase: '今天是星期日', + spaceCase: '今天是星期日', + spaceCamelCase: '今天是星期日', + spacePascalCase: '今天是星期日', + spaceUpperCase: '今天是星期日', + dotCase: '今天是星期日', + dotCamelCase: '今天是星期日', + dotPascalCase: '今天是星期日', + dotUpperCase: '今天是星期日', + lowerCase: '今天是星期日', + upperCase: '今天是星期日', + }, + }, + { + title: 'Chinese input 2', + input: + '--担心你dAf_=coffee—爸妈不在家_— ' + , + eol: [LF, CRLF], + transformText: [ + '担心你|d|af|=|coffee|—爸妈不在家|— ', + ], + output: { + camelCase: '担心你dAf=Coffee—爸妈不在家— ', + pascalCase: '担心你DAf=Coffee—爸妈不在家— ', + snakeCase: '担心你d_af=coffee—爸妈不在家— ', + snakeCamelCase: '担心你d_Af=Coffee—爸妈不在家— ', + snakePascalCase: '担心你D_Af=Coffee—爸妈不在家— ', + snakeUpperCase: '担心你D_AF=COFFEE—爸妈不在家— ', + kebabCase: '担心你d-af=coffee—爸妈不在家— ', + kebabCamelCase: '担心你d-Af=Coffee—爸妈不在家— ', + kebabPascalCase: '担心你D-Af=Coffee—爸妈不在家— ', + kebabUpperCase: '担心你D-AF=COFFEE—爸妈不在家— ', + spaceCase: '担心你d af=coffee—爸妈不在家— ', + spaceCamelCase: '担心你d Af=Coffee—爸妈不在家— ', + spacePascalCase: '担心你D Af=Coffee—爸妈不在家— ', + spaceUpperCase: '担心你D AF=COFFEE—爸妈不在家— ', + dotCase: '担心你d.af=coffee—爸妈不在家— ', + dotCamelCase: '担心你d.Af=Coffee—爸妈不在家— ', + dotPascalCase: '担心你D.Af=Coffee—爸妈不在家— ', + dotUpperCase: '担心你D.AF=COFFEE—爸妈不在家— ', + lowerCase: '--担心你daf_=coffee—爸妈不在家_— ', + upperCase: '--担心你DAF_=COFFEE—爸妈不在家_— ', + }, + }, + { + title: 'Special character with emoji input', + input: + '🥰 a-cup/_of Coffee🍻,-_please.thanks!. ' + , + eol: [LF, CRLF], + transformText: [ + '🥰|a|cup|/|of|coffee|🍻,|please|.|thanks|!. ', + ], + output: { + camelCase: '🥰aCup/OfCoffee🍻,Please.Thanks!. ', + pascalCase: '🥰ACup/OfCoffee🍻,Please.Thanks!. ', + snakeCase: '🥰a_cup/of_coffee🍻,please.thanks!. ', + snakeCamelCase: '🥰a_Cup/Of_Coffee🍻,Please.Thanks!. ', + snakePascalCase: '🥰A_Cup/Of_Coffee🍻,Please.Thanks!. ', + snakeUpperCase: '🥰A_CUP/OF_COFFEE🍻,PLEASE.THANKS!. ', + kebabCase: '🥰a-cup/of-coffee🍻,please.thanks!. ', + kebabCamelCase: '🥰a-Cup/Of-Coffee🍻,Please.Thanks!. ', + kebabPascalCase: '🥰A-Cup/Of-Coffee🍻,Please.Thanks!. ', + kebabUpperCase: '🥰A-CUP/OF-COFFEE🍻,PLEASE.THANKS!. ', + spaceCase: '🥰a cup/of coffee🍻,please.thanks!. ', + spaceCamelCase: '🥰a Cup/Of Coffee🍻,Please.Thanks!. ', + spacePascalCase: '🥰A Cup/Of Coffee🍻,Please.Thanks!. ', + spaceUpperCase: '🥰A CUP/OF COFFEE🍻,PLEASE.THANKS!. ', + dotCase: '🥰a.cup/of.coffee🍻,please.thanks!. ', + dotCamelCase: '🥰a.Cup/Of.Coffee🍻,Please.Thanks!. ', + dotPascalCase: '🥰A.Cup/Of.Coffee🍻,Please.Thanks!. ', + dotUpperCase: '🥰A.CUP/OF.COFFEE🍻,PLEASE.THANKS!. ', + lowerCase: '🥰 a-cup/_of coffee🍻,-_please.thanks!. ', + upperCase: '🥰 A-CUP/_OF COFFEE🍻,-_PLEASE.THANKS!. ', + }, + }, + { + title: 'Special character with multiple input', + input: + 'takeARest😊haPPy,😢triSTE,ENFADADO, 驚きました,❤️, 笑, 😎COol, 😳-Embarrassed' + , + eol: [LF, CRLF], + transformText: [ + 'take|a|rest|😊|ha|p|py|,😢|tri|ste|,|enfadado|,|驚きました,❤️,|笑,|😎|c|ool|,|😳|embarrassed', + ], + output: { + camelCase: 'takeARest😊HaPPy,😢TriSte,Enfadado,驚きました,❤️,笑,😎COol,😳Embarrassed', + pascalCase: 'TakeARest😊HaPPy,😢TriSte,Enfadado,驚きました,❤️,笑,😎COol,😳Embarrassed', + snakeCase: 'take_a_rest😊ha_p_py,😢tri_ste,enfadado,驚きました,❤️,笑,😎c_ool,😳embarrassed', + snakeCamelCase: 'take_A_Rest😊Ha_P_Py,😢Tri_Ste,Enfadado,驚きました,❤️,笑,😎C_Ool,😳Embarrassed', + snakePascalCase: 'Take_A_Rest😊Ha_P_Py,😢Tri_Ste,Enfadado,驚きました,❤️,笑,😎C_Ool,😳Embarrassed', + snakeUpperCase: 'TAKE_A_REST😊HA_P_PY,😢TRI_STE,ENFADADO,驚きました,❤️,笑,😎C_OOL,😳EMBARRASSED', + kebabCase: 'take-a-rest😊ha-p-py,😢tri-ste,enfadado,驚きました,❤️,笑,😎c-ool,😳embarrassed', + kebabCamelCase: 'take-A-Rest😊Ha-P-Py,😢Tri-Ste,Enfadado,驚きました,❤️,笑,😎C-Ool,😳Embarrassed', + kebabPascalCase: 'Take-A-Rest😊Ha-P-Py,😢Tri-Ste,Enfadado,驚きました,❤️,笑,😎C-Ool,😳Embarrassed', + kebabUpperCase: 'TAKE-A-REST😊HA-P-PY,😢TRI-STE,ENFADADO,驚きました,❤️,笑,😎C-OOL,😳EMBARRASSED', + spaceCase: 'take a rest😊ha p py,😢tri ste,enfadado,驚きました,❤️,笑,😎c ool,😳embarrassed', + spaceCamelCase: 'take A Rest😊Ha P Py,😢Tri Ste,Enfadado,驚きました,❤️,笑,😎C Ool,😳Embarrassed', + spacePascalCase: 'Take A Rest😊Ha P Py,😢Tri Ste,Enfadado,驚きました,❤️,笑,😎C Ool,😳Embarrassed', + spaceUpperCase: 'TAKE A REST😊HA P PY,😢TRI STE,ENFADADO,驚きました,❤️,笑,😎C OOL,😳EMBARRASSED', + dotCase: 'take.a.rest😊ha.p.py,😢tri.ste,enfadado,驚きました,❤️,笑,😎c.ool,😳embarrassed', + dotCamelCase: 'take.A.Rest😊Ha.P.Py,😢Tri.Ste,Enfadado,驚きました,❤️,笑,😎C.Ool,😳Embarrassed', + dotPascalCase: 'Take.A.Rest😊Ha.P.Py,😢Tri.Ste,Enfadado,驚きました,❤️,笑,😎C.Ool,😳Embarrassed', + dotUpperCase: 'TAKE.A.REST😊HA.P.PY,😢TRI.STE,ENFADADO,驚きました,❤️,笑,😎C.OOL,😳EMBARRASSED', + lowerCase: 'takearest😊happy,😢triste,enfadado, 驚きました,❤️, 笑, 😎cool, 😳-embarrassed', + upperCase: 'TAKEAREST😊HAPPY,😢TRISTE,ENFADADO, 驚きました,❤️, 笑, 😎COOL, 😳-EMBARRASSED', + }, + }, + { + title: 'Random input', + input: + ' NHDAs--+90-usz&* ' + , + eol: [LF, CRLF], + transformText: [ + ' n|h|d|as|+90|usz|&* ', + ], + output: { + camelCase: ' nHDAs+90Usz&* ', + pascalCase: ' NHDAs+90Usz&* ', + snakeCase: ' n_h_d_as+90usz&* ', + snakeCamelCase: ' n_H_D_As+90Usz&* ', + snakePascalCase: ' N_H_D_As+90Usz&* ', + snakeUpperCase: ' N_H_D_AS+90USZ&* ', + kebabCase: ' n-h-d-as+90usz&* ', + kebabCamelCase: ' n-H-D-As+90Usz&* ', + kebabPascalCase: ' N-H-D-As+90Usz&* ', + kebabUpperCase: ' N-H-D-AS+90USZ&* ', + spaceCase: ' n h d as+90usz&* ', + spaceCamelCase: ' n H D As+90Usz&* ', + spacePascalCase: ' N H D As+90Usz&* ', + spaceUpperCase: ' N H D AS+90USZ&* ', + dotCase: ' n.h.d.as+90usz&* ', + dotCamelCase: ' n.H.D.As+90Usz&* ', + dotPascalCase: ' N.H.D.As+90Usz&* ', + dotUpperCase: ' N.H.D.AS+90USZ&* ', + lowerCase: ' nhdas--+90-usz&* ', + upperCase: ' NHDAS--+90-USZ&* ', + }, + }, + { + title: 'Mixed input 1', + input: + 'fsdi_sdacsaf+desd' + , + eol: [LF, CRLF], + transformText: [ + 'fsdi|sdacsaf|+|desd', + ], + output: { + camelCase: 'fsdiSdacsaf+Desd', + pascalCase: 'FsdiSdacsaf+Desd', + snakeCase: 'fsdi_sdacsaf+desd', + snakeCamelCase: 'fsdi_Sdacsaf+Desd', + snakePascalCase: 'Fsdi_Sdacsaf+Desd', + snakeUpperCase: 'FSDI_SDACSAF+DESD', + kebabCase: 'fsdi-sdacsaf+desd', + kebabCamelCase: 'fsdi-Sdacsaf+Desd', + kebabPascalCase: 'Fsdi-Sdacsaf+Desd', + kebabUpperCase: 'FSDI-SDACSAF+DESD', + spaceCase: 'fsdi sdacsaf+desd', + spaceCamelCase: 'fsdi Sdacsaf+Desd', + spacePascalCase: 'Fsdi Sdacsaf+Desd', + spaceUpperCase: 'FSDI SDACSAF+DESD', + dotCase: 'fsdi.sdacsaf+desd', + dotCamelCase: 'fsdi.Sdacsaf+Desd', + dotPascalCase: 'Fsdi.Sdacsaf+Desd', + dotUpperCase: 'FSDI.SDACSAF+DESD', + lowerCase: 'fsdi_sdacsaf+desd', + upperCase: 'FSDI_SDACSAF+DESD', + }, + }, + // add more cases... + ], + }, + { + group: 'Functional verification', + testTitle: 'Functional verification (功能验证)', + cases: [ + // 正常输入 + { + title: 'Normal input (foo-bar)', + input: [ + 'foo--bar', + '-foo -bar', + '__foo - _bar-__', + ], + eol: [LF, CRLF], + transformText: [ + 'foo|bar', + ], + output: { + camelCase: 'fooBar', + pascalCase: 'FooBar', + snakeCase: 'foo_bar', + snakeCamelCase: 'foo_Bar', + snakePascalCase: 'Foo_Bar', + snakeUpperCase: 'FOO_BAR', + kebabCase: 'foo-bar', + kebabCamelCase: 'foo-Bar', + kebabPascalCase: 'Foo-Bar', + kebabUpperCase: 'FOO-BAR', + spaceCase: 'foo bar', + spaceCamelCase: 'foo Bar', + spacePascalCase: 'Foo Bar', + spaceUpperCase: 'FOO BAR', + dotCase: 'foo.bar', + dotCamelCase: 'foo.Bar', + dotPascalCase: 'Foo.Bar', + dotUpperCase: 'FOO.BAR', + // lowerCase: 'foo--bar', + // upperCase: 'FOO--BAR', + }, + }, + { + title: 'Normal input (test-case)', + input: [ + 'test case', + 'test_case', + 'test-case', + 'testCase', + 'TestCase', + 'TEST_CASE', + ], + eol: [LF, CRLF], + transformText: [ + 'test|case', + ], + output: { + camelCase: 'testCase', + pascalCase: 'TestCase', + snakeCase: 'test_case', + snakeCamelCase: 'test_Case', + snakePascalCase: 'Test_Case', + snakeUpperCase: 'TEST_CASE', + kebabCase: 'test-case', + kebabCamelCase: 'test-Case', + kebabPascalCase: 'Test-Case', + kebabUpperCase: 'TEST-CASE', + spaceCase: 'test case', + spaceCamelCase: 'test Case', + spacePascalCase: 'Test Case', + spaceUpperCase: 'TEST CASE', + dotCase: 'test.case', + dotCamelCase: 'test.Case', + dotPascalCase: 'Test.Case', + dotUpperCase: 'TEST.CASE', + // lowerCase: 'test case', + // upperCase: 'TEST CASE', + }, + }, + { + title: 'Normal input (apple)', + input: [ + 'apple', + 'APPLE', + 'Apple', + ], + eol: [LF, CRLF], + transformText: [ + 'apple', + ], + output: { + camelCase: 'apple', + pascalCase: 'Apple', + snakeCase: 'apple', + snakeCamelCase: 'apple', + snakePascalCase: 'Apple', + snakeUpperCase: 'APPLE', + kebabCase: 'apple', + kebabCamelCase: 'apple', + kebabPascalCase: 'Apple', + kebabUpperCase: 'APPLE', + spaceCase: 'apple', + spaceCamelCase: 'apple', + spacePascalCase: 'Apple', + spaceUpperCase: 'APPLE', + dotCase: 'apple', + dotCamelCase: 'apple', + dotPascalCase: 'Apple', + dotUpperCase: 'APPLE', + lowerCase: 'apple', + upperCase: 'APPLE', + }, + }, + { + title: 'Normal input (pine-apple)', + input: [ + 'pineApple', + ], + eol: [LF, CRLF], + transformText: [ + 'pine|apple', + ], + output: { + camelCase: 'pineApple', + pascalCase: 'PineApple', + snakeCase: 'pine_apple', + snakeCamelCase: 'pine_Apple', + snakePascalCase: 'Pine_Apple', + snakeUpperCase: 'PINE_APPLE', + kebabCase: 'pine-apple', + kebabCamelCase: 'pine-Apple', + kebabPascalCase: 'Pine-Apple', + kebabUpperCase: 'PINE-APPLE', + spaceCase: 'pine apple', + spaceCamelCase: 'pine Apple', + spacePascalCase: 'Pine Apple', + spaceUpperCase: 'PINE APPLE', + dotCase: 'pine.apple', + dotCamelCase: 'pine.Apple', + dotPascalCase: 'Pine.Apple', + dotUpperCase: 'PINE.APPLE', + lowerCase: 'pineapple', + upperCase: 'PINEAPPLE', + }, + }, + { + title: 'Normal input (have-a-nice-day!)', + input: [ + 'Have a nice day!', + 'have a nice day!', + 'Have-a-nice-day!', + 'have-a-nice-day!', + 'HAVE-A-NICE-DAY!', + 'Have_a_nice_day!', + 'have_a_nice_day!', + 'HAVE_A_NICE_DAY!', + 'HaveANiceDay!', + 'haveANiceDay!', + ], + eol: [LF, CRLF], + transformText: [ + 'have|a|nice|day|!', + ], + output: { + camelCase: 'haveANiceDay!', + pascalCase: 'HaveANiceDay!', + snakeCase: 'have_a_nice_day!', + snakeCamelCase: 'have_A_Nice_Day!', + snakePascalCase: 'Have_A_Nice_Day!', + snakeUpperCase: 'HAVE_A_NICE_DAY!', + kebabCase: 'have-a-nice-day!', + kebabCamelCase: 'have-A-Nice-Day!', + kebabPascalCase: 'Have-A-Nice-Day!', + kebabUpperCase: 'HAVE-A-NICE-DAY!', + spaceCase: 'have a nice day!', + spaceCamelCase: 'have A Nice Day!', + spacePascalCase: 'Have A Nice Day!', + spaceUpperCase: 'HAVE A NICE DAY!', + dotCase: 'have.a.nice.day!', + dotCamelCase: 'have.A.Nice.Day!', + dotPascalCase: 'Have.A.Nice.Day!', + dotUpperCase: 'HAVE.A.NICE.DAY!', + // lowerCase: 'have a nice day!', + // upperCase: 'HAVE A NICE DAY!', + }, + }, + { + title: 'Normal input (Dot input: Every day of your life)', + input: '.Every day of your life.. it is..important..to take.the.time to “smell the roses” — to appreciate the experiences that lead to happiness. This is part of being truly happy.', + eol: [LF, CRLF], + transformText: [ + '.|every|day|of|your|life|..|it|is|..|important|..|to|take|.|the|.|time|to|“|smell|the|roses|”|—|to|appreciate|the|experiences|that|lead|to|happiness|.|this|is|part|of|being|truly|happy|.', + ], + output: { + camelCase: + '.everyDayOfYourLife..ItIs..Important..ToTake.The.TimeTo“SmellTheRoses”—ToAppreciateTheExperiencesThatLeadToHappiness.ThisIsPartOfBeingTrulyHappy.' + , + pascalCase: + '.EveryDayOfYourLife..ItIs..Important..ToTake.The.TimeTo“SmellTheRoses”—ToAppreciateTheExperiencesThatLeadToHappiness.ThisIsPartOfBeingTrulyHappy.' + , + snakeCase: + '.every_day_of_your_life..it_is..important..to_take.the.time_to“smell_the_roses”—to_appreciate_the_experiences_that_lead_to_happiness.this_is_part_of_being_truly_happy.' + , + snakeCamelCase: + '.every_Day_Of_Your_Life..It_Is..Important..To_Take.The.Time_To“Smell_The_Roses”—To_Appreciate_The_Experiences_That_Lead_To_Happiness.This_Is_Part_Of_Being_Truly_Happy.' + , + snakePascalCase: + '.Every_Day_Of_Your_Life..It_Is..Important..To_Take.The.Time_To“Smell_The_Roses”—To_Appreciate_The_Experiences_That_Lead_To_Happiness.This_Is_Part_Of_Being_Truly_Happy.' + , + snakeUpperCase: + '.EVERY_DAY_OF_YOUR_LIFE..IT_IS..IMPORTANT..TO_TAKE.THE.TIME_TO“SMELL_THE_ROSES”—TO_APPRECIATE_THE_EXPERIENCES_THAT_LEAD_TO_HAPPINESS.THIS_IS_PART_OF_BEING_TRULY_HAPPY.' + , + kebabCase: + '.every-day-of-your-life..it-is..important..to-take.the.time-to“smell-the-roses”—to-appreciate-the-experiences-that-lead-to-happiness.this-is-part-of-being-truly-happy.' + , + kebabCamelCase: + '.every-Day-Of-Your-Life..It-Is..Important..To-Take.The.Time-To“Smell-The-Roses”—To-Appreciate-The-Experiences-That-Lead-To-Happiness.This-Is-Part-Of-Being-Truly-Happy.' + , + kebabPascalCase: + '.Every-Day-Of-Your-Life..It-Is..Important..To-Take.The.Time-To“Smell-The-Roses”—To-Appreciate-The-Experiences-That-Lead-To-Happiness.This-Is-Part-Of-Being-Truly-Happy.' + , + kebabUpperCase: + '.EVERY-DAY-OF-YOUR-LIFE..IT-IS..IMPORTANT..TO-TAKE.THE.TIME-TO“SMELL-THE-ROSES”—TO-APPRECIATE-THE-EXPERIENCES-THAT-LEAD-TO-HAPPINESS.THIS-IS-PART-OF-BEING-TRULY-HAPPY.' + , + spaceCase: + '.every day of your life..it is..important..to take.the.time to“smell the roses”—to appreciate the experiences that lead to happiness.this is part of being truly happy.' + , + spaceCamelCase: + '.every Day Of Your Life..It Is..Important..To Take.The.Time To“Smell The Roses”—To Appreciate The Experiences That Lead To Happiness.This Is Part Of Being Truly Happy.' + , + spacePascalCase: + '.Every Day Of Your Life..It Is..Important..To Take.The.Time To“Smell The Roses”—To Appreciate The Experiences That Lead To Happiness.This Is Part Of Being Truly Happy.' + , + spaceUpperCase: + '.EVERY DAY OF YOUR LIFE..IT IS..IMPORTANT..TO TAKE.THE.TIME TO“SMELL THE ROSES”—TO APPRECIATE THE EXPERIENCES THAT LEAD TO HAPPINESS.THIS IS PART OF BEING TRULY HAPPY.' + , + dotCase: + '.every.day.of.your.life..it.is..important..to.take.the.time.to“smell.the.roses”—to.appreciate.the.experiences.that.lead.to.happiness.this.is.part.of.being.truly.happy.' + , + dotCamelCase: + '.every.Day.Of.Your.Life..It.Is..Important..To.Take.The.Time.To“Smell.The.Roses”—To.Appreciate.The.Experiences.That.Lead.To.Happiness.This.Is.Part.Of.Being.Truly.Happy.' + , + dotPascalCase: + '.Every.Day.Of.Your.Life..It.Is..Important..To.Take.The.Time.To“Smell.The.Roses”—To.Appreciate.The.Experiences.That.Lead.To.Happiness.This.Is.Part.Of.Being.Truly.Happy.' + , + dotUpperCase: + '.EVERY.DAY.OF.YOUR.LIFE..IT.IS..IMPORTANT..TO.TAKE.THE.TIME.TO“SMELL.THE.ROSES”—TO.APPRECIATE.THE.EXPERIENCES.THAT.LEAD.TO.HAPPINESS.THIS.IS.PART.OF.BEING.TRULY.HAPPY.' + , + lowerCase: + '.every day of your life.. it is..important..to take.the.time to “smell the roses” — to appreciate the experiences that lead to happiness. this is part of being truly happy.' + , + upperCase: + '.EVERY DAY OF YOUR LIFE.. IT IS..IMPORTANT..TO TAKE.THE.TIME TO “SMELL THE ROSES” — TO APPRECIATE THE EXPERIENCES THAT LEAD TO HAPPINESS. THIS IS PART OF BEING TRULY HAPPY.' + , + }, + }, + { + title: 'Normal input (a-nice-day!)', + input: [ + ' A nice day! ', + ' a_nice_day! ', + ' ANiceDay! ', + ' A_NICE_DAY! ', + // ' A_Nice_DaY! ', + // ' A-NiCe_Day! ', + // ' A----NiCe_Day_-_!-- ', + ' A----NICE_Day_-_!-- ', + ], + eol: [LF, CRLF], + transformText: [ + ' a|nice|day|! ', + ], + output: { + camelCase: ' aNiceDay! ', + pascalCase: ' ANiceDay! ', + snakeCase: ' a_nice_day! ', + snakeCamelCase: ' a_Nice_Day! ', + snakePascalCase: ' A_Nice_Day! ', + snakeUpperCase: ' A_NICE_DAY! ', + kebabCase: ' a-nice-day! ', + kebabCamelCase: ' a-Nice-Day! ', + kebabPascalCase: ' A-Nice-Day! ', + kebabUpperCase: ' A-NICE-DAY! ', + spaceCase: ' a nice day! ', + spaceCamelCase: ' a Nice Day! ', + spacePascalCase: ' A Nice Day! ', + spaceUpperCase: ' A NICE DAY! ', + dotCase: ' a.nice.day! ', + dotCamelCase: ' a.Nice.Day! ', + dotPascalCase: ' A.Nice.Day! ', + dotUpperCase: ' A.NICE.DAY! ', + // lowerCase: ' a nice day! ', + // upperCase: ' A NICE DAY! ', + }, + }, + { + title: 'Normal input (a-nice-day)', + input: [ + ' A NICE-Day-', + ' A niceDay', + ], + eol: [LF, CRLF], + transformText: [ + ' a|nice|day', + ], + output: { + camelCase: ' aNiceDay', + pascalCase: ' ANiceDay', + snakeCase: ' a_nice_day', + snakeCamelCase: ' a_Nice_Day', + snakePascalCase: ' A_Nice_Day', + snakeUpperCase: ' A_NICE_DAY', + kebabCase: ' a-nice-day', + kebabCamelCase: ' a-Nice-Day', + kebabPascalCase: ' A-Nice-Day', + kebabUpperCase: ' A-NICE-DAY', + spaceCase: ' a nice day', + spaceCamelCase: ' a Nice Day', + spacePascalCase: ' A Nice Day', + spaceUpperCase: ' A NICE DAY', + dotCase: ' a.nice.day', + dotCamelCase: ' a.Nice.Day', + dotPascalCase: ' A.Nice.Day', + dotUpperCase: ' A.NICE.DAY', + // lowerCase: ' a nice-day-', + // upperCase: ' A NICE-DAY-', + }, + }, + { + title: 'Normal input (tom-likes-eat-ice-cream)', + input: [ + 'TomLikes eat iceCream.', + ], + eol: [LF, CRLF], + transformText: [ + 'tom|likes|eat|ice|cream|.', + ], + output: { + camelCase: 'tomLikesEatIceCream.', + pascalCase: 'TomLikesEatIceCream.', + snakeCase: 'tom_likes_eat_ice_cream.', + snakeCamelCase: 'tom_Likes_Eat_Ice_Cream.', + snakePascalCase: 'Tom_Likes_Eat_Ice_Cream.', + snakeUpperCase: 'TOM_LIKES_EAT_ICE_CREAM.', + kebabCase: 'tom-likes-eat-ice-cream.', + kebabCamelCase: 'tom-Likes-Eat-Ice-Cream.', + kebabPascalCase: 'Tom-Likes-Eat-Ice-Cream.', + kebabUpperCase: 'TOM-LIKES-EAT-ICE-CREAM.', + spaceCase: 'tom likes eat ice cream.', + spaceCamelCase: 'tom Likes Eat Ice Cream.', + spacePascalCase: 'Tom Likes Eat Ice Cream.', + spaceUpperCase: 'TOM LIKES EAT ICE CREAM.', + dotCase: 'tom.likes.eat.ice.cream.', + dotCamelCase: 'tom.Likes.Eat.Ice.Cream.', + dotPascalCase: 'Tom.Likes.Eat.Ice.Cream.', + dotUpperCase: 'TOM.LIKES.EAT.ICE.CREAM.', + lowerCase: 'tomlikes eat icecream.', + upperCase: 'TOMLIKES EAT ICECREAM.', + }, + }, + { + title: 'Normal input (apple-2-Tree)', + input: [ + ' apple2-Tree ', + ' apple2Tree ', + ], + eol: [LF, CRLF], + transformText: [ + ' apple|2|tree ', + ], + output: { + camelCase: ' apple2Tree ', + pascalCase: ' Apple2Tree ', + snakeCase: ' apple2tree ', + snakeCamelCase: ' apple2Tree ', + snakePascalCase: ' Apple2Tree ', + snakeUpperCase: ' APPLE2TREE ', + kebabCase: ' apple2tree ', + kebabCamelCase: ' apple2Tree ', + kebabPascalCase: ' Apple2Tree ', + kebabUpperCase: ' APPLE2TREE ', + spaceCase: ' apple2tree ', + spaceCamelCase: ' apple2Tree ', + spacePascalCase: ' Apple2Tree ', + spaceUpperCase: ' APPLE2TREE ', + dotCase: ' apple2tree ', + dotCamelCase: ' apple2Tree ', + dotPascalCase: ' Apple2Tree ', + dotUpperCase: ' APPLE2TREE ', + // lowerCase: ' apple2-tree ', + // upperCase: ' APPLE2-TREE ', + }, + }, + { + title: 'Normal input (Julius-Caesar, William-Shakespeare, ...)', + input: + ' Julius_Caesar, William_Shakespeare, Albert_Einstein, Marie_Curie, WolfgangAmadeusMozart, Vincent-van-Gogh. ' + , + eol: [LF, CRLF], + transformText: [ + ' julius|caesar|,|william|shakespeare|,|albert|einstein|,|marie|curie|,|wolfgang|amadeus|mozart|,|vincent|van|gogh|. ', + ], + output: { + camelCase: ' juliusCaesar,WilliamShakespeare,AlbertEinstein,MarieCurie,WolfgangAmadeusMozart,VincentVanGogh. ', + pascalCase: ' JuliusCaesar,WilliamShakespeare,AlbertEinstein,MarieCurie,WolfgangAmadeusMozart,VincentVanGogh. ', + snakeCase: ' julius_caesar,william_shakespeare,albert_einstein,marie_curie,wolfgang_amadeus_mozart,vincent_van_gogh. ', + snakeCamelCase: ' julius_Caesar,William_Shakespeare,Albert_Einstein,Marie_Curie,Wolfgang_Amadeus_Mozart,Vincent_Van_Gogh. ', + snakePascalCase: ' Julius_Caesar,William_Shakespeare,Albert_Einstein,Marie_Curie,Wolfgang_Amadeus_Mozart,Vincent_Van_Gogh. ', + snakeUpperCase: ' JULIUS_CAESAR,WILLIAM_SHAKESPEARE,ALBERT_EINSTEIN,MARIE_CURIE,WOLFGANG_AMADEUS_MOZART,VINCENT_VAN_GOGH. ', + kebabCase: ' julius-caesar,william-shakespeare,albert-einstein,marie-curie,wolfgang-amadeus-mozart,vincent-van-gogh. ', + kebabCamelCase: ' julius-Caesar,William-Shakespeare,Albert-Einstein,Marie-Curie,Wolfgang-Amadeus-Mozart,Vincent-Van-Gogh. ', + kebabPascalCase: ' Julius-Caesar,William-Shakespeare,Albert-Einstein,Marie-Curie,Wolfgang-Amadeus-Mozart,Vincent-Van-Gogh. ', + kebabUpperCase: ' JULIUS-CAESAR,WILLIAM-SHAKESPEARE,ALBERT-EINSTEIN,MARIE-CURIE,WOLFGANG-AMADEUS-MOZART,VINCENT-VAN-GOGH. ', + spaceCase: ' julius caesar,william shakespeare,albert einstein,marie curie,wolfgang amadeus mozart,vincent van gogh. ', + spaceCamelCase: ' julius Caesar,William Shakespeare,Albert Einstein,Marie Curie,Wolfgang Amadeus Mozart,Vincent Van Gogh. ', + spacePascalCase: ' Julius Caesar,William Shakespeare,Albert Einstein,Marie Curie,Wolfgang Amadeus Mozart,Vincent Van Gogh. ', + spaceUpperCase: ' JULIUS CAESAR,WILLIAM SHAKESPEARE,ALBERT EINSTEIN,MARIE CURIE,WOLFGANG AMADEUS MOZART,VINCENT VAN GOGH. ', + dotCase: ' julius.caesar,william.shakespeare,albert.einstein,marie.curie,wolfgang.amadeus.mozart,vincent.van.gogh. ', + dotCamelCase: ' julius.Caesar,William.Shakespeare,Albert.Einstein,Marie.Curie,Wolfgang.Amadeus.Mozart,Vincent.Van.Gogh. ', + dotPascalCase: ' Julius.Caesar,William.Shakespeare,Albert.Einstein,Marie.Curie,Wolfgang.Amadeus.Mozart,Vincent.Van.Gogh. ', + dotUpperCase: ' JULIUS.CAESAR,WILLIAM.SHAKESPEARE,ALBERT.EINSTEIN,MARIE.CURIE,WOLFGANG.AMADEUS.MOZART,VINCENT.VAN.GOGH. ', + lowerCase: ' julius_caesar, william_shakespeare, albert_einstein, marie_curie, wolfgangamadeusmozart, vincent-van-gogh. ', + upperCase: ' JULIUS_CAESAR, WILLIAM_SHAKESPEARE, ALBERT_EINSTEIN, MARIE_CURIE, WOLFGANGAMADEUSMOZART, VINCENT-VAN-GOGH. ', + }, + }, + { + title: 'Normal input ("You" (or "Your") ...)', + input: + ' "You" (or "Your") shall mean an individual or Legal Entity\n' + + ' exercising permissions granted by this License.' + , + eol: [LF], + transformText: [ + ' &|quot|;|you|&|quot|;|(|or|&|quot|;|your|&|quot|;)|shall|mean|an|individual|or|legal|entity', + ' exercising|permissions|granted|by|this|license|.', + ], + output: { + camelCase: + ' "You&Quot;(Or&Quot;Your&Quot;)ShallMeanAnIndividualOrLegalEntity\n' + + ' exercisingPermissionsGrantedByThisLicense.' + , + pascalCase: + ' &Quot;You&Quot;(Or&Quot;Your&Quot;)ShallMeanAnIndividualOrLegalEntity\n' + + ' ExercisingPermissionsGrantedByThisLicense.' + , + snakeCase: + ' "you"(or"your")shall_mean_an_individual_or_legal_entity\n' + + ' exercising_permissions_granted_by_this_license.' + , + snakeCamelCase: + ' "You&Quot;(Or&Quot;Your&Quot;)Shall_Mean_An_Individual_Or_Legal_Entity\n' + + ' exercising_Permissions_Granted_By_This_License.' + , + snakePascalCase: + ' &Quot;You&Quot;(Or&Quot;Your&Quot;)Shall_Mean_An_Individual_Or_Legal_Entity\n' + + ' Exercising_Permissions_Granted_By_This_License.' + , + snakeUpperCase: + ' "YOU"(OR"YOUR")SHALL_MEAN_AN_INDIVIDUAL_OR_LEGAL_ENTITY\n' + + ' EXERCISING_PERMISSIONS_GRANTED_BY_THIS_LICENSE.' + , + kebabCase: + ' "you"(or"your")shall-mean-an-individual-or-legal-entity\n' + + ' exercising-permissions-granted-by-this-license.' + , + kebabCamelCase: + ' "You&Quot;(Or&Quot;Your&Quot;)Shall-Mean-An-Individual-Or-Legal-Entity\n' + + ' exercising-Permissions-Granted-By-This-License.' + , + kebabPascalCase: + ' &Quot;You&Quot;(Or&Quot;Your&Quot;)Shall-Mean-An-Individual-Or-Legal-Entity\n' + + ' Exercising-Permissions-Granted-By-This-License.' + , + kebabUpperCase: + ' "YOU"(OR"YOUR")SHALL-MEAN-AN-INDIVIDUAL-OR-LEGAL-ENTITY\n' + + ' EXERCISING-PERMISSIONS-GRANTED-BY-THIS-LICENSE.' + , + spaceCase: + ' "you"(or"your")shall mean an individual or legal entity\n' + + ' exercising permissions granted by this license.' + , + spaceCamelCase: + ' "You&Quot;(Or&Quot;Your&Quot;)Shall Mean An Individual Or Legal Entity\n' + + ' exercising Permissions Granted By This License.' + , + spacePascalCase: + ' &Quot;You&Quot;(Or&Quot;Your&Quot;)Shall Mean An Individual Or Legal Entity\n' + + ' Exercising Permissions Granted By This License.' + , + spaceUpperCase: + ' "YOU"(OR"YOUR")SHALL MEAN AN INDIVIDUAL OR LEGAL ENTITY\n' + + ' EXERCISING PERMISSIONS GRANTED BY THIS LICENSE.' + , + dotCase: + ' "you"(or"your")shall.mean.an.individual.or.legal.entity\n' + + ' exercising.permissions.granted.by.this.license.' + , + dotCamelCase: + ' "You&Quot;(Or&Quot;Your&Quot;)Shall.Mean.An.Individual.Or.Legal.Entity\n' + + ' exercising.Permissions.Granted.By.This.License.' + , + dotPascalCase: + ' &Quot;You&Quot;(Or&Quot;Your&Quot;)Shall.Mean.An.Individual.Or.Legal.Entity\n' + + ' Exercising.Permissions.Granted.By.This.License.' + , + dotUpperCase: + ' "YOU"(OR"YOUR")SHALL.MEAN.AN.INDIVIDUAL.OR.LEGAL.ENTITY\n' + + ' EXERCISING.PERMISSIONS.GRANTED.BY.THIS.LICENSE.' + , + lowerCase: + ' "you" (or "your") shall mean an individual or legal entity\n' + + ' exercising permissions granted by this license.' + , + upperCase: + ' "YOU" (OR "YOUR") SHALL MEAN AN INDIVIDUAL OR LEGAL ENTITY\n' + + ' EXERCISING PERMISSIONS GRANTED BY THIS LICENSE.' + , + }, + }, + // add more cases... + ], + }, + { + group: 'Extreme case verification', + testTitle: 'Extreme case verification (极端情况验证)', + cases: [ + // 极端情况 + + // add more cases... + ], + }, + { + group: 'Xxxx verification', + testTitle: 'Xxxx verification (xxx验证)', + cases: [ + // Description + // { + // title: 'Normal input ( ...)', + // input: '', + // eol: [LF, CRLF], + // transformText: [ + // '', + // ], + // output: { + // camelCase: '', + // pascalCase: '', + // snakeCase: '', + // snakeCamelCase: '', + // snakePascalCase: '', + // snakeUpperCase: '', + // kebabCase: '', + // kebabCamelCase: '', + // kebabPascalCase: '', + // kebabUpperCase: '', + // spaceCase: '', + // spaceCamelCase: '', + // spacePascalCase: '', + // spaceUpperCase: '', + // dotCase: '', + // dotCamelCase: '', + // dotPascalCase: '', + // dotUpperCase: '', + // lowerCase: '', + // upperCase: '', + // }, + // }, + // add more cases... + ], + }, + // add more cases... +]; diff --git a/src/type-definition/EOLType.ts b/src/types/EOLType.ts similarity index 100% rename from src/type-definition/EOLType.ts rename to src/types/EOLType.ts diff --git a/src/type-definition/TransformTextResultType.ts b/src/types/TransformTextResultType.ts similarity index 100% rename from src/type-definition/TransformTextResultType.ts rename to src/types/TransformTextResultType.ts diff --git a/src/main-code/transform.ts b/src/utils/transform.ts similarity index 97% rename from src/main-code/transform.ts rename to src/utils/transform.ts index 814f3e9..0ad0f92 100644 --- a/src/main-code/transform.ts +++ b/src/utils/transform.ts @@ -1,4 +1,4 @@ -import { TransformTextResult } from "../type-definition/TransformTextResultType"; +import { TransformTextResult } from "../types/TransformTextResultType"; const logDebugInfo = false; diff --git a/src/utils/user-configuration.ts b/src/utils/user-configuration.ts new file mode 100644 index 0000000..256ca4a --- /dev/null +++ b/src/utils/user-configuration.ts @@ -0,0 +1,20 @@ +import vscode from 'vscode'; + +/** + * 获取用户配置项 + * + * @param configKey 配置项的键 + * @returns 配置项的值 + * @since 2024-07-29 + */ +function getUserConfigurations(configKey: string): T | undefined { + const config = vscode.workspace.getConfiguration('variable-conversion'); + + const configValue = config.get(configKey); + // console.log('configValue:', configValue); + return configValue; +} + +export { + getUserConfigurations +}; diff --git a/src/main-code/utils.ts b/src/utils/utils.ts similarity index 54% rename from src/main-code/utils.ts rename to src/utils/utils.ts index 7a29c9f..8fc2b80 100644 --- a/src/main-code/utils.ts +++ b/src/utils/utils.ts @@ -1,3 +1,11 @@ +/** + * 比较两个字符串数组 `Array` 是否相同 + * + * @param array1 数组1 + * @param array2 数组2 + * @returns + * @since 2024-04-09 + */ export function isStringArrayEqual(array1: string[], array2: string[]) { if (array1.length !== array2.length) { return false; @@ -12,6 +20,15 @@ export function isStringArrayEqual(array1: string[], array2: string[]) { return true; } +/** + * 去除二维字符串数组中的重复数组元素 + * + * 例如,输入 [["a", "b"], ["a", "b"], ["c", "d"]],会返回 [[ "a", "b"], ["c", "d"]],去除了重复出现的 ["a", "b"]。 + * + * @param stringArr 要进行去重操作的二维字符串数组,即数组中每个元素又是一个字符串数组,代表一组相关的字符串元素集合。 + * @returns 返回一个二维字符串数组,其中已经去除了原输入二维数组中重复的元素组合,基于JSON序列化后的字符串比较来判定重复与否。 + * @since 2024-04-09 + */ export function stringListArrayDuplicateRemoval(stringArr: Array): Array { const tempArr: Array = []; const newArr: Array = [];