Repository navigation
Conversation
When a user opens a single Java file with no workspace folder, or a workspace folder with just a single Java file, show an information message recommending the JBang extension for running Java scripts. Includes option to install the jbang-vscode extension from the marketplace, and a 'Don't Show Again' option to suppress future notifications. Fixes redhat-developer#3111
| ); | ||
|
|
||
| if (choice === install) { | ||
| await commands.executeCommand(Commands.OPEN_BROWSER, Uri.parse(JBANG_MARKETPLACE_URL)); |
There was a problem hiding this comment.
It's possible to actually install the extension for the user instead of just opening the web browser to the website for the extension. The command for this is "workbench.extensions.installExtension" and it accepts the extension id as an argument.
It's also possible to open the extensions panel and enter the extension ID if you think that's too invasive. However, given the user's clicked "Install" I think it's fine to go ahead and install it.
There was a problem hiding this comment.
Agreed.
Change implemented:
In src/extension.ts, the "Install JBang" flow now directly installs the extension instead of opening a web browser:
// Before:
await commands.executeCommand(Commands.OPEN_BROWSER, Uri.parse(JBANG_MARKETPLACE_URL));
// After:
await commands.executeCommand('workbench.extensions.installExtension', JBANG_EXTENSION_ID);
Removed the now-unused JBANG_MARKETPLACE_URL constant.
Kept JBANG_EXTENSION_ID (jbangdev.jbang-vscode) and pass it as the argument to workbench.extensions.installExtension.
direct install command. Signed-off-by: Burhanuddin Vora <burhanuddin.vora@gmail.com>
| "title": "%java.action.copyFullyQualifiedName%", | ||
| "category": "Java" | ||
| }, | ||
| { |
There was a problem hiding this comment.
I don't think this is needed, the command 'java.jbang.recommend' isn't registered anywhere.
There was a problem hiding this comment.
Sure, This command contribution does looks like leftover/dead code. I'll remove it.
|
|
||
| /** | ||
| * Recommend JBang for single Java file usage. | ||
| */ | ||
| export const JBANG_RECOMMEND = 'java.jbang.recommend'; |
There was a problem hiding this comment.
I don't think this is needed, the command 'java.jbang.recommend' isn't registered anywhere.
There was a problem hiding this comment.
Sure, This command contribution does looks like leftover/dead code. I'll remove it.
| "java.runtimes.add": "Add Java Runtime", | ||
| "java.action.copyFullyQualifiedName": "Copy Fully Qualified Name" | ||
| "java.action.copyFullyQualifiedName": "Copy Fully Qualified Name", | ||
| "java.jbang.recommend": "Recommend JBang" |
There was a problem hiding this comment.
I don't think this is needed, the command 'java.jbang.recommend' isn't registered anywhere.
There was a problem hiding this comment.
Sure, This command contribution does looks like leftover/dead code. I'll remove it.
fbricon
left a comment
There was a problem hiding this comment.
I'm not a big fan of the idea, as I said in #3111 (comment), but at the very least the changes should check jbang is not already installed. We added a recommendation library a while ago (#3101), might be worth using it. cc @robstryker.
The java.jbang.recommend command was declared in package.json, src/commands.ts, and package.nls.json but never registered via commands.registerCommand in extension.ts, so it had no handler. The existing showJBangRecommendation() activation logic (extension.ts) is a separate, independent feature that surfaces a notification for single-file Java usage and remains unchanged.
Revert unintended indentation changes (spaces to tabs) and restore the missing trailing newline at end of file. The intentional removal of the unregistered java.jbang.recommend command is preserved.
Revert src/commands.ts to the main branch version, keeping only the package.json and package.nls.json changes that remove the unregistered java.jbang.recommend command declaration.
|
@burhanv14 did you find vscode-extension-proposals to be of any help? It should simplify the implementation significantly; I'm pretty sure it handles setting the context so that it doesn't re-recommend after the user says they're not interested. |
When a user opens a single Java file with no workspace folder (standalone mode) or a workspace with just a single Java file, show an information message recommending the JBang extension for running Java scripts. Includes an "Install JBang" option that opens the jbang-vscode extension in the marketplace, and a "Don't Show Again" option to suppress future notifications.
Fixes #3111