Quick Fix CS0108 & Quick Fix Public
This commit is contained in:
parent
1950c22273
commit
21ac3edc22
BIN
type-script-helper-1.2.9.vsix
Normal file
BIN
type-script-helper-1.2.9.vsix
Normal file
Binary file not shown.
BIN
type-script-helper-1.3.0.vsix
Normal file
BIN
type-script-helper-1.3.0.vsix
Normal file
Binary file not shown.
BIN
type-script-helper-1.3.1.vsix
Normal file
BIN
type-script-helper-1.3.1.vsix
Normal file
Binary file not shown.
@ -67,3 +67,8 @@ Added split(' group by ').join('\r\n GROUP BY ').
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
## Search Google (Read Only Lines Helper)
|
||||
|
||||
### 1.2.9, 1.3.0, 1.3.1
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
## Quick Fix CS0108 & Quick Fix Public
|
||||
|
@ -4,7 +4,7 @@
|
||||
"description": "Helper for VS Code in TypeScript",
|
||||
"publisher": "IFX",
|
||||
"repository": "https://github.com/mikepharesjr/YO-VSCode/tree/master/type-script-helper",
|
||||
"version": "1.2.8",
|
||||
"version": "1.3.1",
|
||||
"engines": {
|
||||
"vscode": "^1.40.0"
|
||||
},
|
||||
@ -22,6 +22,8 @@
|
||||
"onCommand:replaceLinesHelper.listToListFamily",
|
||||
"onCommand:replaceLinesHelper.listToListWrappedComma",
|
||||
"onCommand:replaceLinesHelper.prettySql",
|
||||
"onCommand:replaceLinesHelper.quickFixCS0108",
|
||||
"onCommand:replaceLinesHelper.quickFixPublic",
|
||||
"onCommand:replaceLinesHelper.removeComment",
|
||||
"onCommand:replaceLinesHelper.sortLength",
|
||||
"onCommand:replaceLinesHelper.sortNormal",
|
||||
@ -40,6 +42,8 @@
|
||||
{ "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.quickFixCS0108", "title": "Quick Fix CS0108" },
|
||||
{ "command": "replaceLinesHelper.quickFixPublic", "title": "Quick Fix Public" },
|
||||
{ "command": "replaceLinesHelper.removeComment", "title": "Remove comment" },
|
||||
{ "command": "replaceLinesHelper.sortLength", "title": "Sort by Length" },
|
||||
{ "command": "replaceLinesHelper.sortNormal", "title": "My Sort lines (ascending, case sensitive)" },
|
||||
|
@ -35,6 +35,8 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
vscode.commands.registerCommand('replaceLinesHelper.listToListFamily', replaceLinesHelper.listToListFamily),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.listToListWrappedComma', replaceLinesHelper.listToListWrappedComma),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.prettySql', replaceLinesHelper.prettySql),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.quickFixCS0108', replaceLinesHelper.quickFixCS0108),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.quickFixPublic', replaceLinesHelper.quickFixPublic),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.removeComment', replaceLinesHelper.removeComment),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.sortLength', replaceLinesHelper.sortLength),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.sortNormal', replaceLinesHelper.sortNormal),
|
||||
|
@ -12,6 +12,8 @@ enum LinesAction {
|
||||
listToListFamily,
|
||||
listToListWrappedComma,
|
||||
prettySql,
|
||||
quickFixCS0108,
|
||||
quickFixPublic,
|
||||
pdsfToFixedWidth,
|
||||
removeComment,
|
||||
sortLength,
|
||||
@ -144,6 +146,51 @@ function prettySqlLogic(lines: string[]): void {
|
||||
removeBlanks(lines);
|
||||
}
|
||||
|
||||
function camelCase(str: string) {
|
||||
return str.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function(match, index) {
|
||||
if (+match === 0) return "";
|
||||
return index === 0 ? match.toLowerCase() : match.toUpperCase();
|
||||
});
|
||||
}
|
||||
|
||||
function toCapitalizedWords(name: string) {
|
||||
let words = name.match(/[A-Za-z][a-z]*|[0-9]+/g) || [];
|
||||
return words.map(capitalize).join(" ");
|
||||
}
|
||||
|
||||
function capitalize(word: string) {
|
||||
return word.charAt(0).toUpperCase() + word.substring(1);
|
||||
}
|
||||
|
||||
function quickFixCS0108Logic(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);
|
||||
let capitalizedWords = toCapitalizedWords(properCased);
|
||||
lines[i] = leftPadding + '[Display(Name = "' + capitalizedWords + '"), Required] public new ' + segments[1] + ' ' + properCased + ' { get; set; }';
|
||||
}
|
||||
removeBlanks(lines);
|
||||
}
|
||||
|
||||
function quickFixPublicLogic(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 + 'public ' + segments[1] + ' ' + properCased + ' => ' + camelCased;
|
||||
}
|
||||
removeBlanks(lines);
|
||||
}
|
||||
|
||||
function removeCommentLogic(lines: string[]): void {
|
||||
for (let i = 0; i < lines.length; ++i) {
|
||||
lines[i] = lines[i].trim();
|
||||
@ -265,6 +312,8 @@ function linesFunction(linesAction: LinesAction): Thenable<boolean> | undefined
|
||||
case LinesAction.listToListFamily: { listToListFamilyLogic(lines); break; }
|
||||
case LinesAction.listToListWrappedComma: { listToListWrappedCommaLogic(lines); break; }
|
||||
case LinesAction.prettySql: { prettySqlLogic(lines); break; }
|
||||
case LinesAction.quickFixCS0108: { quickFixCS0108Logic(lines); break; }
|
||||
case LinesAction.quickFixPublic: { quickFixPublicLogic(lines); break; }
|
||||
case LinesAction.removeComment: { removeCommentLogic(lines); break; }
|
||||
case LinesAction.sortLength: { sortLengthLogic(lines); break; }
|
||||
case LinesAction.sortNormal: { sortNormalLogic(lines); break; }
|
||||
@ -284,6 +333,8 @@ export const expandSql = () => linesFunction(LinesAction.expandSql);
|
||||
export const listToListFamily = () => linesFunction(LinesAction.listToListFamily);
|
||||
export const listToListWrappedComma = () => linesFunction(LinesAction.listToListWrappedComma);
|
||||
export const prettySql = () => linesFunction(LinesAction.prettySql);
|
||||
export const quickFixCS0108 = () => linesFunction(LinesAction.quickFixCS0108);
|
||||
export const quickFixPublic = () => linesFunction(LinesAction.quickFixPublic);
|
||||
export const pdsfToFixedWidth = () => linesFunction(LinesAction.pdsfToFixedWidth);
|
||||
export const removeComment = () => linesFunction(LinesAction.removeComment);
|
||||
export const sortLength = () => linesFunction(LinesAction.sortLength);
|
||||
|
Loading…
x
Reference in New Issue
Block a user