Filter out run and debug contextual menu when the file doesn't contain a Main
Run and debug contextual menu are available on files that cannot be run or debug. it would be better to not provide the menu. it will allow having a lighter contextual menu, do nto give false hope to end-users and avoid an error notifications when clicking on it
Environment
- Operating System:
- JDK version:
- Visual Studio Code version:
- Java extension version:
- Java Debugger extension version:
Steps To Reproduce
- create a java file which does not contain a Main class
- right-click on it
[attach a sample project reproducing the error] attach logs
Current Result
Expected Result
Additional Informations
The contextual menu is added statically. To support filter out those files without a main method, we have to watch the file changes to dynamically calculate the main method info of the current file and update the menu registry.
Hi @apupier, I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.
- Currently, the Java Debug extension registers Run/Debug on all
*.javafiles regardless of containing amainmethod. There is no user-facing setting to hide these commands when no entry point exists. - A related discussion is in vscode-java-debug issue #1037, where itβs noted that menus are contributed on every Java file and then the debugger searches the workspace for main classes if none are in the current file.
- To track or request filtering based on presence of a
mainmethod, please upvote or comment on that issue.
labels:
- enhancement
duplicateUrls: []
The team will respond to your issue shortly. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a π. If the suggestion was not helpful or incorrect, please give it a π. Your feedback helps us improve!