Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions src/web/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async function createFile(path: string, filename: string, content: string) {
}
const uintarray = new TextEncoder().encode(content);
await vscode.workspace.fs.writeFile(uri, uintarray);
await vscode.window.showTextDocument(uri, {preview: false});
await vscode.window.showTextDocument(uri, { preview: false });
}

async function findFolder(uri: vscode.Uri): Promise<string> {
Expand All @@ -39,11 +39,11 @@ async function fileExists(uri: vscode.Uri): Promise<boolean> {

export async function createArtifact(uri: vscode.Uri) {
if (uri === undefined) {
vscode.window.showErrorMessage('Right click folder in explorer view', {modal: true});
vscode.window.showErrorMessage('Right click folder in explorer view', { modal: true });
return;
}

const foo: {[name: string]: (uri: vscode.Uri) => Promise<void>} = {
const foo: { [name: string]: (uri: vscode.Uri) => Promise<void> } = {
"CLAS - Class (abapGit)": createCLAS,
"INTF - Interface (abapGit)": createINTF,
"PROG - Program (abapGit)": createPROG,
Expand All @@ -70,7 +70,7 @@ export async function createArtifact(uri: vscode.Uri) {

function createAff(key: string) {
const ret = async (uri: vscode.Uri) => {
let name = await vscode.window.showInputBox({placeHolder: "name"});
let name = await vscode.window.showInputBox({ placeHolder: "name" });
if (name === undefined || name === "") {
return;
}
Expand Down Expand Up @@ -106,7 +106,7 @@ function createAff(key: string) {
}

async function createCLAS(uri: vscode.Uri) {
const name = await vscode.window.showInputBox({placeHolder: "cl_name"});
const name = await vscode.window.showInputBox({ placeHolder: "cl_name" });
if (name === undefined || name === "") {
return;
}
Expand Down Expand Up @@ -142,10 +142,22 @@ CLASS ${name.toLowerCase()} IMPLEMENTATION.

ENDCLASS.`;
await createFile(dir, uriABAP, dataABAP);

const createTestClass = await vscode.window.showQuickPick(
[{ label: "yes" },
{ label: "no" }],
Comment on lines 144 to +148
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new “Add test class include?” prompt runs unconditionally after createFile(dir, uriABAP, ...). If the class files already exist, createFile returns early (after showing an error) and the user will still be prompted and may create a .testclasses.abap include even though the class wasn’t actually created in this run. Consider having createFile return a boolean (created vs. skipped) and only showing the QuickPick (and/or creating the include) when the class creation succeeded.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to avoid changing the interface of createFile for this PR

{ placeHolder: "Add test class include?" }
);

if (createTestClass?.label === "yes") {
const uriTestIncl = filename + ".testclasses" + ".abap";
const dataTestIncl = `*"* use this source file for your ABAP unit test classes`;
await createFile(dir, uriTestIncl, dataTestIncl);
}
}

async function createINTF(uri: vscode.Uri) {
const name = await vscode.window.showInputBox({placeHolder: "if_name"});
const name = await vscode.window.showInputBox({ placeHolder: "if_name" });
if (name === undefined || name === "") {
return;
}
Expand Down Expand Up @@ -179,7 +191,7 @@ ENDINTERFACE.`;
}

async function createPROG(uri: vscode.Uri) {
const name = await vscode.window.showInputBox({placeHolder: "zreport"});
const name = await vscode.window.showInputBox({ placeHolder: "zreport" });
if (name === undefined || name === "") {
return;
}
Expand Down Expand Up @@ -210,11 +222,11 @@ async function createPROG(uri: vscode.Uri) {
}

async function createFUGR(uri: vscode.Uri) {
const groupName = await vscode.window.showInputBox({placeHolder: "z_fugr"});
const groupName = await vscode.window.showInputBox({ placeHolder: "z_fugr" });
if (groupName === undefined || groupName === "") {
return;
}
const moduleName = await vscode.window.showInputBox({placeHolder: "zfunction_module"});
const moduleName = await vscode.window.showInputBox({ placeHolder: "zfunction_module" });
if (moduleName === undefined || moduleName === "") {
return;
}
Expand Down
Loading