Search Google
This commit is contained in:
parent
9efe4e506b
commit
b7453ff4f1
BIN
type-script-helper-1.2.4.vsix
Normal file
BIN
type-script-helper-1.2.4.vsix
Normal file
Binary file not shown.
@ -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.2.3",
|
"version": "1.2.4",
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.40.0"
|
"vscode": "^1.40.0"
|
||||||
},
|
},
|
||||||
@ -22,6 +22,7 @@
|
|||||||
"onCommand:helper.listToListWrappedComma",
|
"onCommand:helper.listToListWrappedComma",
|
||||||
"onCommand:helper.prettySql",
|
"onCommand:helper.prettySql",
|
||||||
"onCommand:helper.removeComment",
|
"onCommand:helper.removeComment",
|
||||||
|
"onCommand:helper.searchGoogle",
|
||||||
"onCommand:helper.sortLength",
|
"onCommand:helper.sortLength",
|
||||||
"onCommand:helper.sortNormal",
|
"onCommand:helper.sortNormal",
|
||||||
"onCommand:helper.unwrapSql",
|
"onCommand:helper.unwrapSql",
|
||||||
@ -39,6 +40,7 @@
|
|||||||
{ "command": "helper.listToListWrappedComma", "title": "List to list wrapped comma" },
|
{ "command": "helper.listToListWrappedComma", "title": "List to list wrapped comma" },
|
||||||
{ "command": "helper.prettySql", "title": "Pretty Sql" },
|
{ "command": "helper.prettySql", "title": "Pretty Sql" },
|
||||||
{ "command": "helper.removeComment", "title": "Remove comment" },
|
{ "command": "helper.removeComment", "title": "Remove comment" },
|
||||||
|
{ "command": "helper.searchGoogle", "title": "Search Google" },
|
||||||
{ "command": "helper.sortLength", "title": "Sort by Length" },
|
{ "command": "helper.sortLength", "title": "Sort by Length" },
|
||||||
{ "command": "helper.sortNormal", "title": "My Sort lines (ascending, case sensitive)" },
|
{ "command": "helper.sortNormal", "title": "My Sort lines (ascending, case sensitive)" },
|
||||||
{ "command": "helper.unwrapSql", "title": "Un-wrap Sql" },
|
{ "command": "helper.unwrapSql", "title": "Un-wrap Sql" },
|
||||||
|
@ -34,6 +34,7 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
vscode.commands.registerCommand('helper.listToListWrappedComma', helper.listToListWrappedComma),
|
vscode.commands.registerCommand('helper.listToListWrappedComma', helper.listToListWrappedComma),
|
||||||
vscode.commands.registerCommand('helper.prettySql', helper.prettySql),
|
vscode.commands.registerCommand('helper.prettySql', helper.prettySql),
|
||||||
vscode.commands.registerCommand('helper.removeComment', helper.removeComment),
|
vscode.commands.registerCommand('helper.removeComment', helper.removeComment),
|
||||||
|
vscode.commands.registerCommand('helper.searchGoogle', helper.searchGoogle),
|
||||||
vscode.commands.registerCommand('helper.sortLength', helper.sortLength),
|
vscode.commands.registerCommand('helper.sortLength', helper.sortLength),
|
||||||
vscode.commands.registerCommand('helper.sortNormal', helper.sortNormal),
|
vscode.commands.registerCommand('helper.sortNormal', helper.sortNormal),
|
||||||
vscode.commands.registerCommand('helper.unwrapSql', helper.unwrapSql),
|
vscode.commands.registerCommand('helper.unwrapSql', helper.unwrapSql),
|
||||||
|
@ -15,6 +15,7 @@ enum LinesAction {
|
|||||||
prettySql,
|
prettySql,
|
||||||
pdsfToFixedWidth,
|
pdsfToFixedWidth,
|
||||||
removeComment,
|
removeComment,
|
||||||
|
searchGoogle,
|
||||||
sortLength,
|
sortLength,
|
||||||
sortNormal,
|
sortNormal,
|
||||||
unwrapSql,
|
unwrapSql,
|
||||||
@ -57,28 +58,28 @@ function convertToRegularExpressionLogic(lines: string[]): string[] {
|
|||||||
let explicitLines = 50;
|
let explicitLines = 50;
|
||||||
for (let i = 0; i < lines.length - 1 && i < explicitLines; ++i) {
|
for (let i = 0; i < lines.length - 1 && i < explicitLines; ++i) {
|
||||||
result = result + lines[i].trim().
|
result = result + lines[i].trim().
|
||||||
split('\\').join('\\\\').
|
split('\\').join('\\\\').
|
||||||
split('(').join('\\(').
|
split('(').join('\\(').
|
||||||
split(')').join('\\)').
|
split(')').join('\\)').
|
||||||
split('[').join('\\[').
|
split('[').join('\\[').
|
||||||
split(']').join('\\]').
|
split(']').join('\\]').
|
||||||
split('{').join('\\{').
|
split('{').join('\\{').
|
||||||
split('}').join('\\}').
|
split('}').join('\\}').
|
||||||
split('.').join('\\.').
|
split('.').join('\\.').
|
||||||
split('*').join('\\*').
|
split('*').join('\\*').
|
||||||
split('+').join('\\+').
|
split('+').join('\\+').
|
||||||
split('?').join('\\?').
|
split('?').join('\\?').
|
||||||
split('|').join('\\|').
|
split('|').join('\\|').
|
||||||
split('$').join('\\$').
|
split('$').join('\\$').
|
||||||
split('^').join('\\^') +
|
split('^').join('\\^') +
|
||||||
'~';
|
'~';
|
||||||
}
|
}
|
||||||
for (let i = explicitLines; i < lines.length - 1; ++i) {
|
for (let i = explicitLines; i < lines.length - 1; ++i) {
|
||||||
result = result + '.*~';
|
result = result + '.*~';
|
||||||
}
|
}
|
||||||
result = result.
|
result = result.
|
||||||
substring(0, result.length - 1).
|
substring(0, result.length - 1).
|
||||||
split('~').join('\\r\\n\?\\s\*');
|
split('~').join('\\r\\n\?\\s\*');
|
||||||
results = [result];
|
results = [result];
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
@ -87,26 +88,26 @@ function expandSqlLogic(lines: string[]): void {
|
|||||||
for (let i = 0; i < lines.length; ++i) {
|
for (let i = 0; i < lines.length; ++i) {
|
||||||
lines[i] = ' ' + lines[i];
|
lines[i] = ' ' + lines[i];
|
||||||
lines[i] = lines[i].
|
lines[i] = lines[i].
|
||||||
split(' select ').join(' SELECT\r\n').
|
split(' select ').join(' SELECT\r\n').
|
||||||
split(' from ').join('\r\n FROM ').
|
split(' from ').join('\r\n FROM ').
|
||||||
split(' where ').join('\r\n WHERE ').
|
split(' where ').join('\r\n WHERE ').
|
||||||
split(' and ').join('\r\n and ').
|
split(' and ').join('\r\n and ').
|
||||||
split(' join ').join('\r\n join ').
|
split(' join ').join('\r\n join ').
|
||||||
split(' left join ').join('\r\n left join ').
|
split(' left join ').join('\r\n left join ').
|
||||||
split(' on ').join('\r\n ON ').
|
split(' on ').join('\r\n ON ').
|
||||||
split(' group by ').join('\r\n GROUP BY ').
|
split(' group by ').join('\r\n GROUP BY ').
|
||||||
split(' order by ').join('\r\n ORDER BY ').
|
split(' order by ').join('\r\n ORDER BY ').
|
||||||
split(' SELECT ').join(' SELECT\r\n').
|
split(' SELECT ').join(' SELECT\r\n').
|
||||||
split(' FROM ').join('\r\n FROM ').
|
split(' FROM ').join('\r\n FROM ').
|
||||||
split(' WHERE ').join('\r\n WHERE ').
|
split(' WHERE ').join('\r\n WHERE ').
|
||||||
split(' AND ').join('\r\n AND ').
|
split(' AND ').join('\r\n AND ').
|
||||||
split(' JOIN ').join('\r\n JOIN ').
|
split(' JOIN ').join('\r\n JOIN ').
|
||||||
split(' LEFT JOIN ').join('\r\n LEFT JOIN ').
|
split(' LEFT JOIN ').join('\r\n LEFT JOIN ').
|
||||||
split(' ON ').join('\r\n ON ').
|
split(' ON ').join('\r\n ON ').
|
||||||
split(' GROUP BY ').join('\r\n GROUP BY ').
|
split(' GROUP BY ').join('\r\n GROUP BY ').
|
||||||
split(' ORDER BY ').join('\r\n ORDER BY ').
|
split(' ORDER BY ').join('\r\n ORDER BY ').
|
||||||
split('\r\n\r\n').join('\r\n').
|
split('\r\n\r\n').join('\r\n').
|
||||||
trim();
|
trim();
|
||||||
}
|
}
|
||||||
removeBlanks(lines);
|
removeBlanks(lines);
|
||||||
prettySqlLogic(lines);
|
prettySqlLogic(lines);
|
||||||
@ -128,19 +129,19 @@ function prettySqlLogic(lines: string[]): void {
|
|||||||
for (let i = 0; i < lines.length; ++i) {
|
for (let i = 0; i < lines.length; ++i) {
|
||||||
lines[i] = ' ' + lines[i];
|
lines[i] = ' ' + lines[i];
|
||||||
lines[i] = lines[i].
|
lines[i] = lines[i].
|
||||||
split(' select ').join(' SELECT ').
|
split(' select ').join(' SELECT ').
|
||||||
split(' distinct ').join(' DISTINCT ').
|
split(' distinct ').join(' DISTINCT ').
|
||||||
split(' as ').join(' AS ').
|
split(' as ').join(' AS ').
|
||||||
split(' from ').join(' FROM ').
|
split(' from ').join(' FROM ').
|
||||||
split(' where ').join(' WHERE ').
|
split(' where ').join(' WHERE ').
|
||||||
split(' and ').join(' AND ').
|
split(' and ').join(' AND ').
|
||||||
split(' join ').join(' JOIN ').
|
split(' join ').join(' JOIN ').
|
||||||
split(' left join ').join(' LEFT JOIN ').
|
split(' left join ').join(' LEFT JOIN ').
|
||||||
split(' on ').join(' ON ').
|
split(' on ').join(' ON ').
|
||||||
split(' group by ').join(' GROUP BY ').
|
split(' group by ').join(' GROUP BY ').
|
||||||
split(' order by ').join(' ORDER BY ').
|
split(' order by ').join(' ORDER BY ').
|
||||||
split('\r\n\r\n').join('\r\n').
|
split('\r\n\r\n').join('\r\n').
|
||||||
trim();
|
trim();
|
||||||
}
|
}
|
||||||
removeBlanks(lines);
|
removeBlanks(lines);
|
||||||
}
|
}
|
||||||
@ -148,15 +149,23 @@ function prettySqlLogic(lines: string[]): void {
|
|||||||
function removeCommentLogic(lines: string[]): void {
|
function removeCommentLogic(lines: string[]): void {
|
||||||
for (let i = 0; i < lines.length; ++i) {
|
for (let i = 0; i < lines.length; ++i) {
|
||||||
lines[i] = lines[i].trim();
|
lines[i] = lines[i].trim();
|
||||||
if(lines[i].length > 1 && lines[i][0] === '/' && lines[i][1] === '/') {
|
if (lines[i].length > 1 && lines[i][0] === '/' && lines[i][1] === '/') {
|
||||||
lines[i] = lines[i].substr(2);
|
lines[i] = lines[i].substr(2);
|
||||||
}
|
}
|
||||||
if(lines[i].length > 0 && lines[i][0] === "'") {
|
if (lines[i].length > 0 && lines[i][0] === "'") {
|
||||||
lines[i] = lines[i].substr(1);
|
lines[i] = lines[i].substr(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function searchGoogleLogic(lines: string[]): void {
|
||||||
|
for (let i = 0; i < lines.length; ++i) {
|
||||||
|
vscode.env.openExternal(
|
||||||
|
vscode.Uri.parse(`https://www.google.com/search?q=${lines[i]}`)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function makeSorter(algorithm?: SortingAlgorithm): ArrayTransformer {
|
function makeSorter(algorithm?: SortingAlgorithm): ArrayTransformer {
|
||||||
return function (lines: string[]): string[] {
|
return function (lines: string[]): string[] {
|
||||||
return lines.sort(algorithm);
|
return lines.sort(algorithm);
|
||||||
@ -175,30 +184,30 @@ function sortNormalLogic(lines: string[]): void {
|
|||||||
function unwrapSqlLogic(lines: string[]): void {
|
function unwrapSqlLogic(lines: string[]): void {
|
||||||
for (let i = 0; i < lines.length; ++i) {
|
for (let i = 0; i < lines.length; ++i) {
|
||||||
lines[i] = "//" + lines[i].
|
lines[i] = "//" + lines[i].
|
||||||
split('sql = "').join('').
|
split('sql = "').join('').
|
||||||
split('sql = sql & "').join('').
|
split('sql = sql & "').join('').
|
||||||
split('sql.Append("').join('').
|
split('sql.Append("').join('').
|
||||||
split('.Append("').join('').
|
split('.Append("').join('').
|
||||||
split('Append("').join('').
|
split('Append("').join('').
|
||||||
split('");').join('').
|
split('");').join('').
|
||||||
split('").').join('').
|
split('").').join('').
|
||||||
split('")').join('').
|
split('")').join('').
|
||||||
split('" & ').join('$').
|
split('" & ').join('$').
|
||||||
split(' & "').join('$').
|
split(' & "').join('$').
|
||||||
split('"').join('').
|
split('"').join('').
|
||||||
trim();
|
trim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function wrapSqlCSharpLogic(lines: string[]): void {
|
function wrapSqlCSharpLogic(lines: string[]): void {
|
||||||
for (let i = 0; i < lines.length; ++i) {
|
for (let i = 0; i < lines.length; ++i) {
|
||||||
lines[i] = lines[i].trim();
|
lines[i] = lines[i].trim();
|
||||||
if(lines[i].length > 1 && lines[i][0] === '/' && lines[i][1] === '/') {
|
if (lines[i].length > 1 && lines[i][0] === '/' && lines[i][1] === '/') {
|
||||||
lines[i] = lines[i].substr(2);
|
lines[i] = lines[i].substr(2);
|
||||||
}
|
}
|
||||||
lines[i] = 'Append(" ' + lines[i] + ' ").';
|
lines[i] = 'Append(" ' + lines[i] + ' ").';
|
||||||
}
|
}
|
||||||
if(lines.length > 0) {
|
if (lines.length > 0) {
|
||||||
lines[0] = 'sql.' + lines[0];
|
lines[0] = 'sql.' + lines[0];
|
||||||
lines[lines.length - 1] = lines[lines.length - 1].split(' ").').join(' ");');
|
lines[lines.length - 1] = lines[lines.length - 1].split(' ").').join(' ");');
|
||||||
}
|
}
|
||||||
@ -207,29 +216,29 @@ function wrapSqlCSharpLogic(lines: string[]): void {
|
|||||||
function wrapSqlVBLogic(lines: string[]): void {
|
function wrapSqlVBLogic(lines: string[]): void {
|
||||||
for (let i = 0; i < lines.length; ++i) {
|
for (let i = 0; i < lines.length; ++i) {
|
||||||
lines[i] = lines[i].trim();
|
lines[i] = lines[i].trim();
|
||||||
if(lines[i].length > 0 && lines[i][0] === "'") {
|
if (lines[i].length > 0 && lines[i][0] === "'") {
|
||||||
lines[i] = lines[i].substr(1);
|
lines[i] = lines[i].substr(1);
|
||||||
}
|
}
|
||||||
lines[i] = 'Append(" ' + lines[i] + ' ").';
|
lines[i] = 'Append(" ' + lines[i] + ' ").';
|
||||||
}
|
}
|
||||||
if(lines.length > 0) {
|
if (lines.length > 0) {
|
||||||
lines[0] = 'sql.' + lines[0];
|
lines[0] = 'sql.' + lines[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortLengthLogic(lines: string[]): void {
|
function sortLengthLogic(lines: string[]): void {
|
||||||
lines.sort(function(a, b) {
|
lines.sort(function (a, b) {
|
||||||
// ASC -> a.length - b.length
|
// ASC -> a.length - b.length
|
||||||
// DESC -> b.length - a.length
|
// DESC -> b.length - a.length
|
||||||
return a.length - b.length || // sort by length, if equal then
|
return a.length - b.length || // sort by length, if equal then
|
||||||
a.localeCompare(b); // sort by dictionary order
|
a.localeCompare(b); // sort by dictionary order
|
||||||
});
|
});
|
||||||
removeBlanks(lines);
|
removeBlanks(lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cutEachLineLogic(lines: string[]): void {
|
function cutEachLineLogic(lines: string[]): void {
|
||||||
for (let i = 0; i < lines.length; ++i) {
|
for (let i = 0; i < lines.length; ++i) {
|
||||||
if(lines[i].length > 0 && lines[i].indexOf("|||") > 0) {
|
if (lines[i].length > 0 && lines[i].indexOf("|||") > 0) {
|
||||||
lines[i] = lines[i].substr(0, lines[i].indexOf("|||"));
|
lines[i] = lines[i].substr(0, lines[i].indexOf("|||"));
|
||||||
}
|
}
|
||||||
lines[i] = lines[i].trim();
|
lines[i] = lines[i].trim();
|
||||||
@ -267,6 +276,7 @@ function linesFunction(linesAction: LinesAction): Thenable<boolean> | undefined
|
|||||||
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.removeComment: { removeCommentLogic(lines); break; }
|
case LinesAction.removeComment: { removeCommentLogic(lines); break; }
|
||||||
|
case LinesAction.searchGoogle: { searchGoogleLogic(lines); break; }
|
||||||
case LinesAction.sortLength: { sortLengthLogic(lines); break; }
|
case LinesAction.sortLength: { sortLengthLogic(lines); break; }
|
||||||
case LinesAction.sortNormal: { sortNormalLogic(lines); break; }
|
case LinesAction.sortNormal: { sortNormalLogic(lines); break; }
|
||||||
case LinesAction.unwrapSql: { unwrapSqlLogic(lines); break; }
|
case LinesAction.unwrapSql: { unwrapSqlLogic(lines); break; }
|
||||||
@ -287,6 +297,7 @@ export const listToListWrappedComma = () => linesFunction(LinesAction.listToList
|
|||||||
export const prettySql = () => linesFunction(LinesAction.prettySql);
|
export const prettySql = () => linesFunction(LinesAction.prettySql);
|
||||||
export const pdsfToFixedWidth = () => linesFunction(LinesAction.pdsfToFixedWidth);
|
export const pdsfToFixedWidth = () => linesFunction(LinesAction.pdsfToFixedWidth);
|
||||||
export const removeComment = () => linesFunction(LinesAction.removeComment);
|
export const removeComment = () => linesFunction(LinesAction.removeComment);
|
||||||
|
export const searchGoogle = () => linesFunction(LinesAction.searchGoogle);
|
||||||
export const sortLength = () => linesFunction(LinesAction.sortLength);
|
export const sortLength = () => linesFunction(LinesAction.sortLength);
|
||||||
export const sortNormal = () => linesFunction(LinesAction.sortNormal);
|
export const sortNormal = () => linesFunction(LinesAction.sortNormal);
|
||||||
export const unwrapSql = () => linesFunction(LinesAction.unwrapSql);
|
export const unwrapSql = () => linesFunction(LinesAction.unwrapSql);
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
],
|
],
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
|
"resolveJsonModule": true,
|
||||||
"strict": true /* enable all strict type-checking options */
|
"strict": true /* enable all strict type-checking options */
|
||||||
/* Additional Checks */
|
/* Additional Checks */
|
||||||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user