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

Added option to delete workspace cache with respect to oracle java extension #124

Merged
merged 1 commit into from
Mar 21, 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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ As soon as one of the settings is changed, the Language Server is restarted.
It is possible to run Oracle Java Platform extension per workspace (VSCode window). This allows separation of Language Server for given project as Language Server JVM is not shared for more VSCode open workspaces (projects).
It is possible to change this in `View | Command Palette | Preferences:Open User Settings | Jdk: Userdir`. Set to `local` to use dedicated Language Server per workspace or set to `global` to have one Language Server for all VS Code workspaces.

## Troubleshooting
If your extension is not starting and throwing some error like no JDK found even if you have a working JDK installed in your machine, then you can try deleting cache for the workspace using `View | Command Palette | Delete oracle java extension cache for this workspace`.

## Contributing

This project welcomes contributions from the community. Before submitting a pull request, please [review our contribution guide](./CONTRIBUTING.md)
Expand Down
3 changes: 3 additions & 0 deletions vscode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ As soon as one of the settings is changed, the Language Server is restarted.
It is possible to run Oracle Java Platform extension per workspace (VSCode window). This allows separation of Language Server for given project as Language Server JVM is not shared for more VSCode open workspaces (projects).
It is possible to change this in `View | Command Palette | Preferences:Open User Settings | Jdk: Userdir`. Set to `local` to use dedicated Language Server per workspace or set to `global` to have one Language Server for all VS Code workspaces.

## Troubleshooting
If your extension is not starting and throwing some error like no JDK found even if you have a working JDK installed in your machine, then you can try deleting cache for the workspace using `View | Command Palette | Delete oracle java extension cache for this workspace`.

## Contributing

This project welcomes contributions from the community. Before submitting a pull request, please [review our contribution guide](../CONTRIBUTING.md)
Expand Down
4 changes: 4 additions & 0 deletions vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@
"command": "jdk.goto.test",
"title": "Go To Test/Tested class...",
"category": "Java"
},
{
"command": "jdk.delete.cache",
"title": "Delete oracle java extension cache for this workspace"
Copy link

@StanFromTraction StanFromTraction Mar 23, 2024

Choose a reason for hiding this comment

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

Oracle and Java should be capitalised @Achal1607

}
],
"keybindings": [
Expand Down
23 changes: 23 additions & 0 deletions vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,29 @@ export function activate(context: ExtensionContext): VSNetBeansAPI {
throw `Client ${c} doesn't support go to test`;
}
}));

context.subscriptions.push(vscode.commands.registerCommand(COMMAND_PREFIX + ".delete.cache", async () => {
const storagePath = context.storageUri?.fsPath;
if(!storagePath){
vscode.window.showErrorMessage('Cannot find workspace path');
return;
}
const userDir = path.join(storagePath, "userdir");
if (userDir && fs.existsSync(userDir)) {
const confirmation = await vscode.window.showInformationMessage('Are you sure you want to delete cache for this workspace?',
'Yes', 'Cancel');
if (confirmation === 'Yes') {
await fs.promises.rmdir(userDir, {recursive : true});
const res = await vscode.window.showInformationMessage('Cache cleared successfully for this workspace', 'Reload window');
if (res === 'Reload window') {
await vscode.commands.executeCommand('workbench.action.reloadWindow');
}
}
} else {
vscode.window.showErrorMessage('Cannot find userdir path');
}
}));

context.subscriptions.push(vscode.commands.registerCommand(COMMAND_PREFIX + ".download.jdk", async () => { openJDKSelectionView(log); }));
context.subscriptions.push(commands.registerCommand(COMMAND_PREFIX + '.workspace.compile', () =>
wrapCommandWithProgress(COMMAND_PREFIX + '.build.workspace', 'Compiling workspace...', log, true)
Expand Down