Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:java sample code #77

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions src/Utg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,20 @@

// Define the test file name by appending 'Test' to the original class name
const originalClassName = path.basename(sourceFilePath, '.java');
const testFileName = `${originalClassName}Test.java`;
const testFileName = `${originalClassName}Tests.java`;
const testFilePath = path.join(fullTestDir, testFileName);
const JavaClassName = `${originalClassName}Tests`

Check warning on line 150 in src/Utg.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Missing semicolon

Check warning on line 150 in src/Utg.ts

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Missing semicolon

Check warning on line 150 in src/Utg.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Missing semicolon

testFilePaths.push(testFilePath);

if (!fs.existsSync(testFilePath)) {
vscode.window.showInformationMessage("Test doesn't exist", testFilePath);

// **Create Test File Content with Proper Package and JUnit Imports**
const testFileContent = `package ${packageName};`;
const testFileContent = `package ${packageName};\n\n
class ${JavaClassName} {\n
}\n`;

fs.writeFileSync(testFilePath, testFileContent);
vscode.window.showInformationMessage(`Created test file: ${testFilePath}`);
console.log(`🐰 Created test file with package name: ${testFilePath}`);
Expand Down
13 changes: 11 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
if (
fileName.endsWith('.test.js') ||
fileName.endsWith('.test.ts') ||
fileName.endsWith('Tests.java') || // Check for Java test file ending
fileName.endsWith('Test.java') || // Check for Java test file ending
fileName.includes('/Test') || // Check for Java test file prefix in the path
fileName.includes('/test/') || // Skip files in a "tests" directory
Expand Down Expand Up @@ -296,7 +297,11 @@
continue;
}

const tree = parser.parse(text);
const options: TreeSitter.Options = {
bufferSize: 1024 * 1024,
};

const tree = parser.parse(text, undefined, options); // Parse the document text
const cursor = tree.walk();
let found = false;

Expand Down Expand Up @@ -414,8 +419,12 @@
console.log('🐰 Unsupported file type:', filePath);
throw new Error("Unsupported file type");
}
const options: TreeSitter.Options = {
bufferSize: 1024 * 1024,
};

const tree = parser.parse(text, undefined, options); // Parse the document text

const tree = parser.parse(text);
const cursor = tree.walk();
const functionNames: string[] = [];

Expand Down Expand Up @@ -704,7 +713,7 @@
ExtentionName = FileExtentionName;
FunctionFilePath = filePath;
vscode.commands.executeCommand('workbench.view.extension.Keploy-Sidebar');
sidebarProvider.postMessage("KeployChatBot")

Check warning on line 716 in src/extension.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Missing semicolon

Check warning on line 716 in src/extension.ts

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Missing semicolon

Check warning on line 716 in src/extension.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Missing semicolon
});

context.subscriptions.push(showSidebarDisposable);
Expand All @@ -712,7 +721,7 @@
let runAdditionalPrompts = vscode.commands.registerCommand('keploy.runAdditionalPrompts', async (additionalPrompts: string) => {
console.log("value inside the function: ", functionName, ExtentionName, additionalPrompts);
await vscode.commands.executeCommand('keploy.utg', FunctionFilePath, functionName, ExtentionName, additionalPrompts);
})

Check warning on line 724 in src/extension.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Missing semicolon

Check warning on line 724 in src/extension.ts

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Missing semicolon

Check warning on line 724 in src/extension.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Missing semicolon

context.subscriptions.push(runAdditionalPrompts);

Expand Down
Loading