1.3.3, 1.3.4 - Quick Fix - Instance Field to Calisthenics

This commit is contained in:
Mike Phares 2021-12-24 21:42:32 -07:00
parent fe9a91d1cb
commit 90339198fb
7 changed files with 2505 additions and 1096 deletions

Binary file not shown.

Binary file not shown.

View File

@ -20,6 +20,18 @@ None
## 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:
cd "L:\GitHub\YO-VSCode\type-script-helper"
@ -75,3 +87,8 @@ Added split(' group by ').join('\r\n GROUP BY ').
## Quick Fix - CS0108 (Data Annotations)
## Quick Fix - Proper Case Properties
## Quick Fix - Public (Expression Body)
### 1.3.3, 1.3.4
-----------------------------------------------------------------------------------------------------------
## Quick Fix - Instance Field to Calisthenics

File diff suppressed because it is too large Load Diff

View File

@ -1,68 +1,130 @@
{
"name": "type-script-helper",
"displayName": "Type Script Helper",
"description": "Helper for VS Code in TypeScript",
"publisher": "IFX",
"repository": "https://github.com/mikepharesjr/YO-VSCode/tree/master/type-script-helper",
"version": "1.3.2",
"engines": {
"displayName": "Type Script Helper",
"description": "Helper for VS Code in TypeScript",
"publisher": "IFX",
"repository": "https://github.com/mikepharesjr/YO-VSCode/tree/master/type-script-helper",
"version": "1.3.4",
"engines": {
"vscode": "^1.40.0"
},
"categories": [
"Other"
],
"main": "./out/extension.js",
"activationEvents": [
"onCommand:readOnlyLinesHelper.searchGoogle",
"onCommand:replaceLinesHelper.addCSharpComment",
"onCommand:replaceLinesHelper.addVBComment",
"onCommand:replaceLinesHelper.convertToRegularExpression",
"onCommand:replaceLinesHelper.cutEachLine",
"onCommand:replaceLinesHelper.expandSql",
"onCommand:replaceLinesHelper.listToListFamily",
"onCommand:replaceLinesHelper.listToListWrappedComma",
"onCommand:replaceLinesHelper.prettySql",
"onCommand:replaceLinesHelper.quickFixCamelCaseProperties",
"onCommand:replaceLinesHelper.quickFixCS0108",
"onCommand:replaceLinesHelper.quickFixProperCaseProperties",
"onCommand:replaceLinesHelper.quickFixPublic",
"onCommand:replaceLinesHelper.removeComment",
"onCommand:replaceLinesHelper.sortLength",
"onCommand:replaceLinesHelper.sortNormal",
"onCommand:replaceLinesHelper.unwrapSql",
"onCommand:replaceLinesHelper.wrapSqlCSharp",
"onCommand:replaceLinesHelper.wrapSqlVB"
],
"contributes": {
"main": "./out/extension.js",
"activationEvents": [
"onCommand:readOnlyLinesHelper.searchGoogle",
"onCommand:replaceLinesHelper.addCSharpComment",
"onCommand:replaceLinesHelper.addVBComment",
"onCommand:replaceLinesHelper.convertToRegularExpression",
"onCommand:replaceLinesHelper.cutEachLine",
"onCommand:replaceLinesHelper.expandSql",
"onCommand:replaceLinesHelper.listToListFamily",
"onCommand:replaceLinesHelper.listToListWrappedComma",
"onCommand:replaceLinesHelper.prettySql",
"onCommand:replaceLinesHelper.quickFixCamelCaseProperties",
"onCommand:replaceLinesHelper.quickFixCS0108",
"onCommand:replaceLinesHelper.quickFixInstanceFieldToCalisthenics",
"onCommand:replaceLinesHelper.quickFixProperCaseProperties",
"onCommand:replaceLinesHelper.quickFixPublic",
"onCommand:replaceLinesHelper.removeComment",
"onCommand:replaceLinesHelper.sortLength",
"onCommand:replaceLinesHelper.sortNormal",
"onCommand:replaceLinesHelper.unwrapSql",
"onCommand:replaceLinesHelper.wrapSqlCSharp",
"onCommand:replaceLinesHelper.wrapSqlVB"
],
"contributes": {
"commands": [
{ "command": "readOnlyLinesHelper.searchGoogle", "title": "Search Google" },
{ "command": "replaceLinesHelper.addCSharpComment", "title": "Add C# Comment" },
{ "command": "replaceLinesHelper.addVBComment", "title": "Add VB Comment" },
{ "command": "replaceLinesHelper.convertToRegularExpression", "title": "Convert to Regular Expression" },
{ "command": "replaceLinesHelper.cutEachLine", "title": "Cut each line after |||" },
{ "command": "replaceLinesHelper.expandSql", "title": "Expand Sql" },
{ "command": "replaceLinesHelper.listToListFamily", "title": "List to list family (Kristy, Mike ...)" },
{ "command": "replaceLinesHelper.listToListWrappedComma", "title": "List to list wrapped comma" },
{ "command": "replaceLinesHelper.prettySql", "title": "Pretty Sql" },
{ "command": "replaceLinesHelper.quickFixCamelCaseProperties", "title": "Quick Fix - Camel Case Properties" },
{ "command": "replaceLinesHelper.quickFixCS0108", "title": "Quick Fix - CS0108 (Data Annotations)" },
{ "command": "replaceLinesHelper.quickFixProperCaseProperties", "title": "Quick Fix - Proper Case Properties" },
{ "command": "replaceLinesHelper.quickFixPublic", "title": "Quick Fix - Public (Expression Body)" },
{ "command": "replaceLinesHelper.removeComment", "title": "Remove comment" },
{ "command": "replaceLinesHelper.sortLength", "title": "Sort by Length" },
{ "command": "replaceLinesHelper.sortNormal", "title": "My Sort lines (ascending, case sensitive)" },
{ "command": "replaceLinesHelper.unwrapSql", "title": "Un-wrap Sql" },
{ "command": "replaceLinesHelper.wrapSqlCSharp", "title": "Wrap Sql for C#" },
{ "command": "replaceLinesHelper.wrapSqlVB", "title": "Wrap Sql for VB" }
{
"command": "readOnlyLinesHelper.searchGoogle",
"title": "Search Google"
},
{
"command": "replaceLinesHelper.addCSharpComment",
"title": "Add C# Comment"
},
{
"command": "replaceLinesHelper.addVBComment",
"title": "Add VB Comment"
},
{
"command": "replaceLinesHelper.convertToRegularExpression",
"title": "Convert to Regular Expression"
},
{
"command": "replaceLinesHelper.cutEachLine",
"title": "Cut each line after |||"
},
{
"command": "replaceLinesHelper.expandSql",
"title": "Expand Sql"
},
{
"command": "replaceLinesHelper.listToListFamily",
"title": "List to list family (Kristy, Mike ...)"
},
{
"command": "replaceLinesHelper.listToListWrappedComma",
"title": "List to list wrapped comma"
},
{
"command": "replaceLinesHelper.prettySql",
"title": "Pretty Sql"
},
{
"command": "replaceLinesHelper.quickFixCamelCaseProperties",
"title": "Quick Fix - Camel Case Properties"
},
{
"command": "replaceLinesHelper.quickFixCS0108",
"title": "Quick Fix - CS0108 (Data Annotations)"
},
{
"command": "replaceLinesHelper.quickFixInstanceFieldToCalisthenics",
"title": "Quick Fix - Instance Field to Calisthenics"
},
{
"command": "replaceLinesHelper.quickFixProperCaseProperties",
"title": "Quick Fix - Proper Case Properties"
},
{
"command": "replaceLinesHelper.quickFixPublic",
"title": "Quick Fix - Public (Expression Body)"
},
{
"command": "replaceLinesHelper.removeComment",
"title": "Remove comment"
},
{
"command": "replaceLinesHelper.sortLength",
"title": "Sort by Length"
},
{
"command": "replaceLinesHelper.sortNormal",
"title": "My Sort lines (ascending, case sensitive)"
},
{
"command": "replaceLinesHelper.unwrapSql",
"title": "Un-wrap Sql"
},
{
"command": "replaceLinesHelper.wrapSqlCSharp",
"title": "Wrap Sql for C#"
},
{
"command": "replaceLinesHelper.wrapSqlVB",
"title": "Wrap Sql for VB"
}
],
"keybindings": [
{
"command": "replaceLinesHelper.unwrapSql",
"key": "shift + f9",
"when": "editorTextFocus"
}
],
"menus": {
"keybindings": [
{
"command": "replaceLinesHelper.unwrapSql",
"key": "shift + f9",
"when": "editorTextFocus"
}
],
"menus": {
"editor/context": [
{
"command": "replaceLinesHelper.unwrapSql",
@ -74,20 +136,20 @@
},
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"pretest": "npm run compile",
"test": "node ./out/test/runTest.js"
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"pretest": "npm run compile",
"test": "node ./out/test/runTest.js"
},
"devDependencies": {
"@types/glob": "^7.1.1",
"@types/mocha": "^5.2.7",
"@types/node": "^12.11.7",
"@types/vscode": "^1.40.0",
"glob": "^7.1.5",
"mocha": "^6.2.2",
"typescript": "^3.6.4",
"tslint": "^5.20.0",
"vscode-test": "^1.2.2"
"@types/mocha": "^5.2.7",
"@types/node": "^12.11.7",
"@types/vscode": "^1.40.0",
"glob": "^7.1.5",
"mocha": "^6.2.2",
"tslint": "^5.20.0",
"typescript": "^3.9.10",
"vscode-test": "^1.2.2"
}
}

View File

@ -37,6 +37,7 @@ export function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand('replaceLinesHelper.prettySql', replaceLinesHelper.prettySql),
vscode.commands.registerCommand('replaceLinesHelper.quickFixCamelCaseProperties', replaceLinesHelper.quickFixCamelCaseProperties),
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.quickFixPublic', replaceLinesHelper.quickFixPublic),
vscode.commands.registerCommand('replaceLinesHelper.removeComment', replaceLinesHelper.removeComment),

View File

@ -14,6 +14,7 @@ enum LinesAction {
prettySql,
quickFixCamelCaseProperties,
quickFixCS0108,
quickFixInstanceFieldToCalisthenics,
quickFixProperCaseProperties,
quickFixPublic,
pdsfToFixedWidth,
@ -192,6 +193,40 @@ function quickFixCS0108Logic(lines: string[]): void {
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 {
for (let i = 0; i < lines.length; ++i) {
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.quickFixCamelCaseProperties: { quickFixCamelCasePropertiesLogic(lines); break; }
case LinesAction.quickFixCS0108: { quickFixCS0108Logic(lines); break; }
case LinesAction.quickFixInstanceFieldToCalisthenics: { quickFixInstanceFieldToCalisthenicsLogic(lines); break; }
case LinesAction.quickFixProperCaseProperties: { quickFixProperCasePropertiesLogic(lines); break; }
case LinesAction.quickFixPublic: { quickFixPublicLogic(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 quickFixCamelCaseProperties = () => linesFunction(LinesAction.quickFixCamelCaseProperties);
export const quickFixCS0108 = () => linesFunction(LinesAction.quickFixCS0108);
export const quickFixInstanceFieldToCalisthenics = () => linesFunction(LinesAction.quickFixInstanceFieldToCalisthenics);
export const quickFixProperCaseProperties = () => linesFunction(LinesAction.quickFixProperCaseProperties);
export const quickFixPublic = () => linesFunction(LinesAction.quickFixPublic);
export const pdsfToFixedWidth = () => linesFunction(LinesAction.pdsfToFixedWidth);