vscode-java-debug icon indicating copy to clipboard operation
vscode-java-debug copied to clipboard

Filter out run and debug contextual menu when the file doesn't contain a Main

Open apupier opened this issue 4 years ago β€’ 2 comments

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
  1. create a java file which does not contain a Main class
  2. right-click on it

[attach a sample project reproducing the error] attach logs

Current Result
Expected Result
Additional Informations

apupier avatar Jan 19 '21 15:01 apupier

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.

testforstephen avatar Jan 20 '21 02:01 testforstephen

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 *.java files regardless of containing a main method. 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 main method, 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!

github-actions[bot] avatar Nov 11 '25 09:11 github-actions[bot]