1.3.3 - Code Generator - $ClassName$, ...
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
import * as vscode from 'vscode';
|
||||
import * as replaceLinesHelper from './replaceLinesHelper';
|
||||
import * as readOnlyLinesHelper from './readOnlyLinesHelper';
|
||||
import * as promiseLinesHelper from './promiseLinesHelper';
|
||||
|
||||
// this method is called when your extension is activated
|
||||
// your extension is activated the very first time the command is executed
|
||||
@ -29,6 +30,7 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
vscode.commands.registerCommand('readOnlyLinesHelper.searchGoogle', readOnlyLinesHelper.searchGoogle),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.addCSharpComment', replaceLinesHelper.addCSharpComment),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.addVBComment', replaceLinesHelper.addVBComment),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.codeGeneratorQuickPick', promiseLinesHelper.codeGeneratorQuickPick),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.convertToRegularExpression', replaceLinesHelper.convertToRegularExpression),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.cutEachLine', replaceLinesHelper.cutEachLine),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.expandSql', replaceLinesHelper.expandSql),
|
||||
|
77
type-script-helper/src/promiseLinesHelper.ts
Normal file
77
type-script-helper/src/promiseLinesHelper.ts
Normal file
@ -0,0 +1,77 @@
|
||||
import * as vscode from 'vscode';
|
||||
import { QuickPickItem } from "vscode";
|
||||
|
||||
function codeGeneratorQuickPickLogic(): undefined {
|
||||
const textEditor = vscode.window.activeTextEditor;
|
||||
if (!textEditor) {
|
||||
return undefined;
|
||||
}
|
||||
let thenable = vscode.window.showQuickPick(
|
||||
[
|
||||
{
|
||||
label: "Class name",
|
||||
detail: "Segments Minus One (Object || Array)",
|
||||
output: "$ClassName$"
|
||||
}, {
|
||||
label: "Type",
|
||||
detail: "Segments Minus One (!Object && !Array)",
|
||||
output: "$Type$"
|
||||
}, {
|
||||
label: "Suggested Type",
|
||||
detail: "Type based on values in *.json file",
|
||||
output: "$SuggestedType$"
|
||||
}, {
|
||||
label: "Full Path",
|
||||
detail: "Full Path and name in padded format",
|
||||
output: "$Debug$"
|
||||
}, {
|
||||
label: "Name",
|
||||
detail: "Segments Last only name (no path)",
|
||||
output: "$Name$"
|
||||
}, {
|
||||
label: "Class name (Camel-Cased)",
|
||||
detail: "Segments Minus One (Object || Array)",
|
||||
output: "ClassNameCamel$"
|
||||
}, {
|
||||
label: "Type (Camel-Cased)",
|
||||
detail: "Segments Minus One (!Object && !Array)",
|
||||
output: "TypeCamel$"
|
||||
}, {
|
||||
label: "Suggested Type (Camel-Cased)",
|
||||
detail: "Type based on values in *.json file",
|
||||
output: "SuggestedTypeCamel$"
|
||||
}, {
|
||||
label: "Full Path (Camel-Cased)",
|
||||
detail: "Full Path and name in padded format",
|
||||
output: "$DebugCamel$"
|
||||
}, {
|
||||
label: "Name (Camel-Cased)",
|
||||
detail: "Segments Last only name (no path)",
|
||||
output: "$NameCamel$"
|
||||
}, {
|
||||
label: "Name (Camel-Cased and Plural)",
|
||||
detail: "Segments Last only name (no path)",
|
||||
output: "$NameCamelPlural$"
|
||||
}
|
||||
]
|
||||
).then(item => {
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
const selection = textEditor.selection;
|
||||
return textEditor.edit(editBuilder => {
|
||||
var range;
|
||||
if (selection.isEmpty) {
|
||||
editBuilder.insert(selection.start, item.output)
|
||||
}
|
||||
else {
|
||||
range = new vscode.Range(selection.start.line, selection.start.character, selection.end.line, selection.end.character);
|
||||
editBuilder.replace(range, item.output);
|
||||
}
|
||||
});
|
||||
});
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export const codeGeneratorQuickPick = () => codeGeneratorQuickPickLogic();
|
||||
export const open = () => codeGeneratorQuickPickLogic();
|
Reference in New Issue
Block a user