Skip to content

Commit 251299f

Browse files
Add Class entry to New File quickpick
Co-authored-by: gjsjohnmurray <6726799+gjsjohnmurray@users.noreply.github.com>
1 parent c2cb122 commit 251299f

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,11 @@
591591
}
592592
],
593593
"file/newFile": [
594+
{
595+
"command": "vscode-objectscript.newFile.class",
596+
"when": "workspaceFolderCount != 0",
597+
"group": "file"
598+
},
594599
{
595600
"command": "vscode-objectscript.newFile.kpi",
596601
"when": "workspaceFolderCount != 0",
@@ -1021,6 +1026,11 @@
10211026
"command": "vscode-objectscript.loadStudioColors",
10221027
"title": "Load Studio Syntax Colors"
10231028
},
1029+
{
1030+
"category": "ObjectScript",
1031+
"command": "vscode-objectscript.newFile.class",
1032+
"title": "Class"
1033+
},
10241034
{
10251035
"category": "ObjectScript",
10261036
"command": "vscode-objectscript.newFile.kpi",

src/commands/newFile.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ function getAdapterPrompt(adapters: InputStepItem[], type: AdapaterClassType): I
222222

223223
/** The types of classes we can create */
224224
export enum NewFileType {
225+
Class = "Class",
225226
BusinessOperation = "Business Operation",
226227
BusinessService = "Business Service",
227228
BPL = "Business Process",
@@ -262,7 +263,7 @@ export async function newFile(type: NewFileType): Promise<void> {
262263
api = undefined;
263264
}
264265

265-
if (type != NewFileType.KPI) {
266+
if (type != NewFileType.KPI && type != NewFileType.Class) {
266267
// Check if we're connected to an Interoperability namespace
267268
const ensemble: boolean = api
268269
? await api.getNamespace().then((data) => data.result.content.features[0].enabled)
@@ -402,7 +403,7 @@ export async function newFile(type: NewFileType): Promise<void> {
402403
inputSteps.push(
403404
{
404405
type: "inputBox",
405-
title: `Enter a name for the new ${type} class`,
406+
title: `Enter a name for the new ${type == NewFileType.Class ? "class" : type + " class"}`,
406407
placeholder: "Package.Subpackage.Class",
407408
validateInput: (value: string) => {
408409
const valid = validateClassName(value);
@@ -933,6 +934,23 @@ Parameter RESPONSECLASSNAME As CLASSNAME = "${respClass}";`
933934
/// InterSystems IRIS purges message bodies based on the class when the option to purge message bodies is enabled
934935
Parameter ENSPURGE As BOOLEAN = 1;
935936
937+
}
938+
`;
939+
} else if (type == NewFileType.Class) {
940+
// Prompt the user
941+
const results = await multiStepInput(inputSteps);
942+
if (!results) {
943+
return;
944+
}
945+
cls = results[0];
946+
const [, desc] = results;
947+
948+
// Generate the file's content
949+
clsContent = `
950+
${typeof desc == "string" ? "/// " + desc.replace(/\n/g, "\n/// ") : ""}
951+
Class ${cls}
952+
{
953+
936954
}
937955
`;
938956
}

src/extension.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,10 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
16071607
sendCommandTelemetryEvent("loadStudioColors");
16081608
loadStudioColors(languageServerExt);
16091609
}),
1610+
vscode.commands.registerCommand("vscode-objectscript.newFile.class", () => {
1611+
sendCommandTelemetryEvent("newFile.class");
1612+
newFile(NewFileType.Class);
1613+
}),
16101614
vscode.commands.registerCommand("vscode-objectscript.newFile.businessOperation", () => {
16111615
sendCommandTelemetryEvent("newFile.businessOperation");
16121616
newFile(NewFileType.BusinessOperation);

0 commit comments

Comments
 (0)