Skip to content

feat: recommend JBang for single Java file usage - #4573

Open
burhanv14 wants to merge 7 commits into
redhat-developer:mainfrom
burhanv14:feature/jbang-recommendation
Open

burhanv14 wants to merge 7 commits into
redhat-developer:mainfrom
burhanv14:feature/jbang-recommendation

Conversation

@burhanv14

@burhanv14 burhanv14 commented Nov 13, 2026 •

Copy link
Copy Markdown

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

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
Comment thread src/extension.ts Outdated
);

if (choice === install) {
await commands.executeCommand(Commands.OPEN_BROWSER, Uri.parse(JBANG_MARKETPLACE_URL));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@burhanv14 burhanv14 Nov 14, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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>
@burhanv14
burhanv14 requested a review from datho7561 November 14, 2026 21:06
Comment thread package.json Outdated
"title": "%java.action.copyFullyQualifiedName%",
"category": "Java"
},
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this is needed, the command 'java.jbang.recommend' isn't registered anywhere.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sure, This command contribution does looks like leftover/dead code. I'll remove it.

Comment thread src/commands.ts Outdated
Comment on lines +371 to +375

/**
* Recommend JBang for single Java file usage.
*/
export const JBANG_RECOMMEND = 'java.jbang.recommend';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this is needed, the command 'java.jbang.recommend' isn't registered anywhere.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sure, This command contribution does looks like leftover/dead code. I'll remove it.

Comment thread package.nls.json Outdated
"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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this is needed, the command 'java.jbang.recommend' isn't registered anywhere.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sure, This command contribution does looks like leftover/dead code. I'll remove it.

@fbricon fbricon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.
@datho7561

Copy link
Copy Markdown
Contributor

@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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider recommendation to install JBang

3 participants