This commit is contained in:
Mike Phares 2022-01-11 20:21:19 -07:00
commit b3a9f0e822
7 changed files with 979 additions and 1058 deletions

Binary file not shown.

Binary file not shown.

View File

@ -20,6 +20,18 @@ None
## Release Notes ## Release Notes
npm install -g vsce
npm install typescript --save-dev
L:
cd "L:\GitHub\YO-VSCode\type-script-helper"
npm install typescript
npx tsc
L: L:
cd "L:\GitHub\YO-VSCode\type-script-helper" cd "L:\GitHub\YO-VSCode\type-script-helper"
@ -75,8 +87,8 @@ Added split(' group by ').join('\r\n GROUP BY ').
## Quick Fix - CS0108 (Data Annotations) ## Quick Fix - CS0108 (Data Annotations)
## Quick Fix - Proper Case Properties ## Quick Fix - Proper Case Properties
## Quick Fix - Public (Expression Body) ## Quick Fix - Public (Expression Body)
### 1.3.3
### 1.3.3, 1.3.4
----------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------------------
## Code Generator - $ClassName$, ... ## Quick Fix - Instance Field to Calisthenics
## Learned - If you add dependencies to package.json then run "npm install" it adds the dependency to node_modules "npm run compile" to build

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
"description": "Helper for VS Code in TypeScript", "description": "Helper for VS Code in TypeScript",
"publisher": "IFX", "publisher": "IFX",
"repository": "https://github.com/mikepharesjr/YO-VSCode/tree/master/type-script-helper", "repository": "https://github.com/mikepharesjr/YO-VSCode/tree/master/type-script-helper",
"version": "1.3.3", "version": "1.3.4",
"engines": { "engines": {
"vscode": "^1.40.0" "vscode": "^1.40.0"
}, },
@ -16,7 +16,6 @@
"onCommand:readOnlyLinesHelper.searchGoogle", "onCommand:readOnlyLinesHelper.searchGoogle",
"onCommand:replaceLinesHelper.addCSharpComment", "onCommand:replaceLinesHelper.addCSharpComment",
"onCommand:replaceLinesHelper.addVBComment", "onCommand:replaceLinesHelper.addVBComment",
"onCommand:replaceLinesHelper.codeGeneratorQuickPick",
"onCommand:replaceLinesHelper.convertToRegularExpression", "onCommand:replaceLinesHelper.convertToRegularExpression",
"onCommand:replaceLinesHelper.cutEachLine", "onCommand:replaceLinesHelper.cutEachLine",
"onCommand:replaceLinesHelper.expandSql", "onCommand:replaceLinesHelper.expandSql",
@ -25,6 +24,7 @@
"onCommand:replaceLinesHelper.prettySql", "onCommand:replaceLinesHelper.prettySql",
"onCommand:replaceLinesHelper.quickFixCamelCaseProperties", "onCommand:replaceLinesHelper.quickFixCamelCaseProperties",
"onCommand:replaceLinesHelper.quickFixCS0108", "onCommand:replaceLinesHelper.quickFixCS0108",
"onCommand:replaceLinesHelper.quickFixInstanceFieldToCalisthenics",
"onCommand:replaceLinesHelper.quickFixProperCaseProperties", "onCommand:replaceLinesHelper.quickFixProperCaseProperties",
"onCommand:replaceLinesHelper.quickFixPublic", "onCommand:replaceLinesHelper.quickFixPublic",
"onCommand:replaceLinesHelper.removeComment", "onCommand:replaceLinesHelper.removeComment",
@ -48,10 +48,6 @@
"command": "replaceLinesHelper.addVBComment", "command": "replaceLinesHelper.addVBComment",
"title": "Add VB Comment" "title": "Add VB Comment"
}, },
{
"command": "replaceLinesHelper.codeGeneratorQuickPick",
"title": "Code Generator - Quick Pick"
},
{ {
"command": "replaceLinesHelper.convertToRegularExpression", "command": "replaceLinesHelper.convertToRegularExpression",
"title": "Convert to Regular Expression" "title": "Convert to Regular Expression"
@ -84,6 +80,10 @@
"command": "replaceLinesHelper.quickFixCS0108", "command": "replaceLinesHelper.quickFixCS0108",
"title": "Quick Fix - CS0108 (Data Annotations)" "title": "Quick Fix - CS0108 (Data Annotations)"
}, },
{
"command": "replaceLinesHelper.quickFixInstanceFieldToCalisthenics",
"title": "Quick Fix - Instance Field to Calisthenics"
},
{ {
"command": "replaceLinesHelper.quickFixProperCaseProperties", "command": "replaceLinesHelper.quickFixProperCaseProperties",
"title": "Quick Fix - Proper Case Properties" "title": "Quick Fix - Proper Case Properties"
@ -147,9 +147,9 @@
"@types/node": "^12.11.7", "@types/node": "^12.11.7",
"@types/vscode": "^1.40.0", "@types/vscode": "^1.40.0",
"glob": "^7.1.5", "glob": "^7.1.5",
"mocha": "^9.1.3", "mocha": "^6.2.2",
"tslint": "^5.20.0", "tslint": "^5.20.0",
"typescript": "^3.6.4", "typescript": "^3.9.10",
"vscode-test": "^1.2.2" "vscode-test": "^1.2.2"
} }
} }

View File

@ -39,6 +39,7 @@ export function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand('replaceLinesHelper.prettySql', replaceLinesHelper.prettySql), vscode.commands.registerCommand('replaceLinesHelper.prettySql', replaceLinesHelper.prettySql),
vscode.commands.registerCommand('replaceLinesHelper.quickFixCamelCaseProperties', replaceLinesHelper.quickFixCamelCaseProperties), vscode.commands.registerCommand('replaceLinesHelper.quickFixCamelCaseProperties', replaceLinesHelper.quickFixCamelCaseProperties),
vscode.commands.registerCommand('replaceLinesHelper.quickFixCS0108', replaceLinesHelper.quickFixCS0108), vscode.commands.registerCommand('replaceLinesHelper.quickFixCS0108', replaceLinesHelper.quickFixCS0108),
vscode.commands.registerCommand('replaceLinesHelper.quickFixInstanceFieldToCalisthenics', replaceLinesHelper.quickFixInstanceFieldToCalisthenics),
vscode.commands.registerCommand('replaceLinesHelper.quickFixProperCaseProperties', replaceLinesHelper.quickFixProperCaseProperties), vscode.commands.registerCommand('replaceLinesHelper.quickFixProperCaseProperties', replaceLinesHelper.quickFixProperCaseProperties),
vscode.commands.registerCommand('replaceLinesHelper.quickFixPublic', replaceLinesHelper.quickFixPublic), vscode.commands.registerCommand('replaceLinesHelper.quickFixPublic', replaceLinesHelper.quickFixPublic),
vscode.commands.registerCommand('replaceLinesHelper.removeComment', replaceLinesHelper.removeComment), vscode.commands.registerCommand('replaceLinesHelper.removeComment', replaceLinesHelper.removeComment),

View File

@ -14,6 +14,7 @@ enum LinesAction {
prettySql, prettySql,
quickFixCamelCaseProperties, quickFixCamelCaseProperties,
quickFixCS0108, quickFixCS0108,
quickFixInstanceFieldToCalisthenics,
quickFixProperCaseProperties, quickFixProperCaseProperties,
quickFixPublic, quickFixPublic,
pdsfToFixedWidth, pdsfToFixedWidth,
@ -192,6 +193,40 @@ function quickFixCS0108Logic(lines: string[]): void {
removeBlanks(lines); removeBlanks(lines);
} }
function quickFixInstanceFieldToCalisthenicsLogic(lines: string[]): void {
for (let i = 0; i < lines.length; ++i) {
let segments = lines[i].trim().split(' ');
if(segments.length !== 2)
continue;
let leftPadding = lines[i].substring(0, lines[i].indexOf(segments[0]));
let type = segments[0];
let name = segments[1].split(';')[0];
let singularName = name;
if(name[name.length - 1] === 's') {
if(name[name.length - 2] === 'e') {
if(name[name.length - 3] === 'i') {
singularName = name.substring(0, singularName.length - 3) + 'y';
}
else
singularName = name.substring(0, singularName.length - 2);
}
else
singularName = name.substring(0, singularName.length - 1);
}
segments = type.split('<');
if(segments.length === 2)
lines[i] = leftPadding + 'public ' + segments[0] + '<' + singularName + '> ' + name + ' { get; } //' + segments[1].split('>')[0];
else {
segments = type.split('[');
if(segments.length === 2)
lines[i] = leftPadding + 'public ' + singularName + '[] ' + name + ' { get; } //' + segments[0];
else
lines[i] = leftPadding + 'public ' + singularName + ' ' + name + ' { get; } //' + type;
}
}
removeBlanks(lines);
}
function quickFixProperCasePropertiesLogic(lines: string[]): void { function quickFixProperCasePropertiesLogic(lines: string[]): void {
for (let i = 0; i < lines.length; ++i) { for (let i = 0; i < lines.length; ++i) {
let segments = lines[i].trim().split(' '); let segments = lines[i].trim().split(' ');
@ -343,6 +378,7 @@ function linesFunction(linesAction: LinesAction): Thenable<boolean> | undefined
case LinesAction.prettySql: { prettySqlLogic(lines); break; } case LinesAction.prettySql: { prettySqlLogic(lines); break; }
case LinesAction.quickFixCamelCaseProperties: { quickFixCamelCasePropertiesLogic(lines); break; } case LinesAction.quickFixCamelCaseProperties: { quickFixCamelCasePropertiesLogic(lines); break; }
case LinesAction.quickFixCS0108: { quickFixCS0108Logic(lines); break; } case LinesAction.quickFixCS0108: { quickFixCS0108Logic(lines); break; }
case LinesAction.quickFixInstanceFieldToCalisthenics: { quickFixInstanceFieldToCalisthenicsLogic(lines); break; }
case LinesAction.quickFixProperCaseProperties: { quickFixProperCasePropertiesLogic(lines); break; } case LinesAction.quickFixProperCaseProperties: { quickFixProperCasePropertiesLogic(lines); break; }
case LinesAction.quickFixPublic: { quickFixPublicLogic(lines); break; } case LinesAction.quickFixPublic: { quickFixPublicLogic(lines); break; }
case LinesAction.removeComment: { removeCommentLogic(lines); break; } case LinesAction.removeComment: { removeCommentLogic(lines); break; }
@ -366,6 +402,7 @@ export const listToListWrappedComma = () => linesFunction(LinesAction.listToList
export const prettySql = () => linesFunction(LinesAction.prettySql); export const prettySql = () => linesFunction(LinesAction.prettySql);
export const quickFixCamelCaseProperties = () => linesFunction(LinesAction.quickFixCamelCaseProperties); export const quickFixCamelCaseProperties = () => linesFunction(LinesAction.quickFixCamelCaseProperties);
export const quickFixCS0108 = () => linesFunction(LinesAction.quickFixCS0108); export const quickFixCS0108 = () => linesFunction(LinesAction.quickFixCS0108);
export const quickFixInstanceFieldToCalisthenics = () => linesFunction(LinesAction.quickFixInstanceFieldToCalisthenics);
export const quickFixProperCaseProperties = () => linesFunction(LinesAction.quickFixProperCaseProperties); export const quickFixProperCaseProperties = () => linesFunction(LinesAction.quickFixProperCaseProperties);
export const quickFixPublic = () => linesFunction(LinesAction.quickFixPublic); export const quickFixPublic = () => linesFunction(LinesAction.quickFixPublic);
export const pdsfToFixedWidth = () => linesFunction(LinesAction.pdsfToFixedWidth); export const pdsfToFixedWidth = () => linesFunction(LinesAction.pdsfToFixedWidth);