This commit is contained in:
2021-12-04 00:00:16 -07:00
parent 21ac3edc22
commit fe9a91d1cb
5 changed files with 47 additions and 5 deletions

Binary file not shown.

View File

@ -68,7 +68,10 @@ Added split(' group by ').join('\r\n GROUP BY ').
## Search Google (Read Only Lines Helper) ## Search Google (Read Only Lines Helper)
### 1.2.9, 1.3.0, 1.3.1 ### 1.2.9, 1.3.0, 1.3.1, 1.3.2
----------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------------------
## Quick Fix CS0108 & Quick Fix Public ## Quick Fix - Camel Case Properties
## Quick Fix - CS0108 (Data Annotations)
## Quick Fix - Proper Case Properties
## Quick Fix - Public (Expression Body)

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.1", "version": "1.3.2",
"engines": { "engines": {
"vscode": "^1.40.0" "vscode": "^1.40.0"
}, },
@ -22,7 +22,9 @@
"onCommand:replaceLinesHelper.listToListFamily", "onCommand:replaceLinesHelper.listToListFamily",
"onCommand:replaceLinesHelper.listToListWrappedComma", "onCommand:replaceLinesHelper.listToListWrappedComma",
"onCommand:replaceLinesHelper.prettySql", "onCommand:replaceLinesHelper.prettySql",
"onCommand:replaceLinesHelper.quickFixCamelCaseProperties",
"onCommand:replaceLinesHelper.quickFixCS0108", "onCommand:replaceLinesHelper.quickFixCS0108",
"onCommand:replaceLinesHelper.quickFixProperCaseProperties",
"onCommand:replaceLinesHelper.quickFixPublic", "onCommand:replaceLinesHelper.quickFixPublic",
"onCommand:replaceLinesHelper.removeComment", "onCommand:replaceLinesHelper.removeComment",
"onCommand:replaceLinesHelper.sortLength", "onCommand:replaceLinesHelper.sortLength",
@ -42,8 +44,10 @@
{ "command": "replaceLinesHelper.listToListFamily", "title": "List to list family (Kristy, Mike ...)" }, { "command": "replaceLinesHelper.listToListFamily", "title": "List to list family (Kristy, Mike ...)" },
{ "command": "replaceLinesHelper.listToListWrappedComma", "title": "List to list wrapped comma" }, { "command": "replaceLinesHelper.listToListWrappedComma", "title": "List to list wrapped comma" },
{ "command": "replaceLinesHelper.prettySql", "title": "Pretty Sql" }, { "command": "replaceLinesHelper.prettySql", "title": "Pretty Sql" },
{ "command": "replaceLinesHelper.quickFixCS0108", "title": "Quick Fix CS0108" }, { "command": "replaceLinesHelper.quickFixCamelCaseProperties", "title": "Quick Fix - Camel Case Properties" },
{ "command": "replaceLinesHelper.quickFixPublic", "title": "Quick Fix Public" }, { "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.removeComment", "title": "Remove comment" },
{ "command": "replaceLinesHelper.sortLength", "title": "Sort by Length" }, { "command": "replaceLinesHelper.sortLength", "title": "Sort by Length" },
{ "command": "replaceLinesHelper.sortNormal", "title": "My Sort lines (ascending, case sensitive)" }, { "command": "replaceLinesHelper.sortNormal", "title": "My Sort lines (ascending, case sensitive)" },

View File

@ -35,7 +35,9 @@ export function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand('replaceLinesHelper.listToListFamily', replaceLinesHelper.listToListFamily), vscode.commands.registerCommand('replaceLinesHelper.listToListFamily', replaceLinesHelper.listToListFamily),
vscode.commands.registerCommand('replaceLinesHelper.listToListWrappedComma', replaceLinesHelper.listToListWrappedComma), vscode.commands.registerCommand('replaceLinesHelper.listToListWrappedComma', replaceLinesHelper.listToListWrappedComma),
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.quickFixCS0108', replaceLinesHelper.quickFixCS0108), vscode.commands.registerCommand('replaceLinesHelper.quickFixCS0108', replaceLinesHelper.quickFixCS0108),
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),
vscode.commands.registerCommand('replaceLinesHelper.sortLength', replaceLinesHelper.sortLength), vscode.commands.registerCommand('replaceLinesHelper.sortLength', replaceLinesHelper.sortLength),

View File

@ -12,7 +12,9 @@ enum LinesAction {
listToListFamily, listToListFamily,
listToListWrappedComma, listToListWrappedComma,
prettySql, prettySql,
quickFixCamelCaseProperties,
quickFixCS0108, quickFixCS0108,
quickFixProperCaseProperties,
quickFixPublic, quickFixPublic,
pdsfToFixedWidth, pdsfToFixedWidth,
removeComment, removeComment,
@ -162,6 +164,19 @@ function capitalize(word: string) {
return word.charAt(0).toUpperCase() + word.substring(1); return word.charAt(0).toUpperCase() + word.substring(1);
} }
function quickFixCamelCasePropertiesLogic(lines: string[]): void {
for (let i = 0; i < lines.length; ++i) {
let segments = lines[i].trim().split(' ');
if(segments.length < 2 || segments.length > 3)
continue;
let leftPadding = lines[i].substring(0, lines[i].indexOf(segments[0]));
if (segments.length === 2) segments = ('protected ' + lines[i].trim()).split(' ');
let camelCased = camelCase(segments[2]);
lines[i] = leftPadding + segments[0] + ' ' + segments[1] + ' ' + camelCased;
}
removeBlanks(lines);
}
function quickFixCS0108Logic(lines: string[]): void { function quickFixCS0108Logic(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(' ');
@ -177,6 +192,20 @@ function quickFixCS0108Logic(lines: string[]): void {
removeBlanks(lines); removeBlanks(lines);
} }
function quickFixProperCasePropertiesLogic(lines: string[]): void {
for (let i = 0; i < lines.length; ++i) {
let segments = lines[i].trim().split(' ');
if(segments.length < 2 || segments.length > 3)
continue;
let leftPadding = lines[i].substring(0, lines[i].indexOf(segments[0]));
if (segments.length === 2) segments = ('protected ' + lines[i].trim()).split(' ');
let camelCased = camelCase(segments[2]);
let properCased = camelCased.substring(0, 1).toUpperCase() + camelCased.substring(1, camelCased.length - 1);
lines[i] = leftPadding + segments[0] + ' ' + segments[1] + ' ' + properCased + ';';
}
removeBlanks(lines);
}
function quickFixPublicLogic(lines: string[]): void { function quickFixPublicLogic(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(' ');
@ -312,7 +341,9 @@ function linesFunction(linesAction: LinesAction): Thenable<boolean> | undefined
case LinesAction.listToListFamily: { listToListFamilyLogic(lines); break; } case LinesAction.listToListFamily: { listToListFamilyLogic(lines); break; }
case LinesAction.listToListWrappedComma: { listToListWrappedCommaLogic(lines); break; } case LinesAction.listToListWrappedComma: { listToListWrappedCommaLogic(lines); break; }
case LinesAction.prettySql: { prettySqlLogic(lines); break; } case LinesAction.prettySql: { prettySqlLogic(lines); break; }
case LinesAction.quickFixCamelCaseProperties: { quickFixCamelCasePropertiesLogic(lines); break; }
case LinesAction.quickFixCS0108: { quickFixCS0108Logic(lines); break; } case LinesAction.quickFixCS0108: { quickFixCS0108Logic(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; }
case LinesAction.sortLength: { sortLengthLogic(lines); break; } case LinesAction.sortLength: { sortLengthLogic(lines); break; }
@ -333,7 +364,9 @@ export const expandSql = () => linesFunction(LinesAction.expandSql);
export const listToListFamily = () => linesFunction(LinesAction.listToListFamily); export const listToListFamily = () => linesFunction(LinesAction.listToListFamily);
export const listToListWrappedComma = () => linesFunction(LinesAction.listToListWrappedComma); export const listToListWrappedComma = () => linesFunction(LinesAction.listToListWrappedComma);
export const prettySql = () => linesFunction(LinesAction.prettySql); export const prettySql = () => linesFunction(LinesAction.prettySql);
export const quickFixCamelCaseProperties = () => linesFunction(LinesAction.quickFixCamelCaseProperties);
export const quickFixCS0108 = () => linesFunction(LinesAction.quickFixCS0108); export const quickFixCS0108 = () => linesFunction(LinesAction.quickFixCS0108);
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);
export const removeComment = () => linesFunction(LinesAction.removeComment); export const removeComment = () => linesFunction(LinesAction.removeComment);