Skip to content

Commit 4cf07b2

Browse files
committed
add message
1 parent 0665711 commit 4cf07b2

File tree

2 files changed

+75
-19
lines changed

2 files changed

+75
-19
lines changed

extension.js

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,9 @@ function activate(context) {
597597
async function () {
598598
//Get workspace folder
599599
if (vscode.workspace.workspaceFolders.length == 0) {
600-
vscode.window.showErrorMessage('Open a folder!');
600+
vscode.window.showErrorMessage(
601+
'Open a folder in your workspace!'
602+
);
601603
return;
602604
}
603605
let workspacefolderUri = undefined;
@@ -609,7 +611,7 @@ function activate(context) {
609611
let choice = undefined;
610612
await vscode.window
611613
.showQuickPick(wsfList, {
612-
placeHolder: 'Select a workspace folder:',
614+
placeHolder: 'Select a folder:',
613615
})
614616
.then(
615617
(value) => {
@@ -640,8 +642,13 @@ function activate(context) {
640642
let kind = undefined;
641643
await vscode.window
642644
.showQuickPick(
643-
['Class', 'Business Service', 'Business Operation'],
644-
{ placeHolder: 'What do you want to generate?' }
645+
[
646+
'Class',
647+
'Business Service',
648+
'Business Operation',
649+
'Message',
650+
],
651+
{ placeHolder: 'New' }
645652
)
646653
.then(
647654
(value) => {
@@ -654,6 +661,7 @@ function activate(context) {
654661
}
655662
);
656663
if (kind == undefined) return;
664+
// get class name and package
657665
let className = await vscode.window.showInputBox({
658666
placeHolder: 'Class Name',
659667
});
@@ -665,21 +673,29 @@ function activate(context) {
665673

666674
let text = undefined;
667675

668-
//class
669-
if (kind == 'Class') {
670-
text = await wizard.createClass(className, packageName);
671-
}
672-
if (kind == 'Business Service') {
673-
text = await wizard.createBusinessService(
674-
className,
675-
packageName
676-
);
677-
}
678-
if (kind == 'Business Operation') {
679-
text = await wizard.createBusinessOperation(
680-
className,
681-
packageName
682-
);
676+
// get the code
677+
switch (kind) {
678+
case 'Class':
679+
text = await wizard.createClass(className, packageName);
680+
break;
681+
case 'Business Service':
682+
text = await wizard.createBusinessService(
683+
className,
684+
packageName
685+
);
686+
break;
687+
case 'Business Operation':
688+
text = await wizard.createBusinessOperation(
689+
className,
690+
packageName
691+
);
692+
break;
693+
case 'Message':
694+
text = await wizard.createMessage(className, packageName);
695+
break;
696+
default:
697+
vscode.window.showErrorMessage('Something went wrong!');
698+
return;
683699
}
684700

685701
if (text == undefined) return;

wizard.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,48 @@ async function createBusinessOperation(packageName, className) {
357357
return text;
358358
}
359359

360+
async function createMessage(packageName, className) {
361+
let kind = await vscode.window.showQuickPick(['Request', 'Response'], {
362+
placeHolder: 'Message Type:',
363+
});
364+
if (kind == undefined) return undefined;
365+
366+
let properties = '';
367+
368+
while (true) {
369+
//property Name
370+
let propName = await vscode.window.showInputBox({
371+
placeHolder: 'Property Name (leave empty to exit)',
372+
});
373+
if (propName == undefined) return undefined;
374+
if (propName == '') {
375+
break;
376+
}
377+
//Method Name
378+
let propType = await vscode.window.showInputBox({
379+
placeHolder: 'Property Type',
380+
});
381+
if (propType == undefined) return undefined;
382+
383+
properties += 'Property ' + propName + ' As ' + propType + ';\n\n';
384+
}
385+
386+
let text =
387+
'Class ' +
388+
packageName +
389+
'.' +
390+
className +
391+
' Extends ' +
392+
(kind == 'Request' ? 'Ens.Request' : 'Ens.Response') +
393+
' \n{ \n\n' +
394+
properties +
395+
'}';
396+
return text;
397+
}
398+
360399
module.exports = {
361400
createClass,
362401
createBusinessService,
363402
createBusinessOperation,
403+
createMessage,
364404
};

0 commit comments

Comments
 (0)