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

Make editor's run/debug command names more specific

Open weinand opened this issue 4 years ago • 7 comments

With the arrival of the new "run/debug" split-button we are trying to come up with some good naming conventions (and since the Java extension is always a good first adopter, we are starting here).

These are the commands used today:

image

Since the commands are contributed only for *.java files, the "Java" in the "Run Java" name is somewhat redundant. Wouldn't it be more helpful to refer to the file's entry point and use "Run Main" and "Debug Main"?

And if the Java file contains tests, then "Run Tests" and "Debug Tests" could be used?

weinand avatar Aug 03 '21 10:08 weinand

Just came back from vacation, sorry for the late response.

In the beginning, we just called the menus "Run" and "Debug". Later, we decided to adopt the contribution point of the Run menu. Considering the Code Runner extension also named it "Run". To avoid confusion, we added some suffixes. Now since Code Runner named the menu "Run Code", I can remove the suffix "Java".

Regarding name suggestions like "Run Main" and "Run Tests", since these menus are statically registered by package.json, there seems to be no easy way to distinguish whether the current Java file is a main class or a test class. Currently, it's Java debugger to register a common menu item, then at runtime, delegate to the appropriate extension (Java Test Runner or Java Debugger) to run the Java file.

testforstephen avatar Aug 09 '21 07:08 testforstephen

@testforstephen yes, the menus are statically registered in the package.json, but you can use a "when" clause to control the contributions. E.g. you could introduce a "hasJavaMain" context and use that to show the "Run Main" and "Debug Main" commands. In your Java Extension just call vscode.commands.executeCommand('setContext', 'hasJavaMain', true); For details see https://github.com/Microsoft/vscode/issues/10471

weinand avatar Aug 10 '21 08:08 weinand

@connor4312 I'd like to ask if you will consider to expose the run test in current file command into the editor/title/run?

jdneo avatar Aug 10 '21 09:08 jdneo

@weinand thank you for the information. We agree to let Java Debugger and Java Test Runner extensions to contribute the menu separately.

For "Run Main" menu, another idea is to change it to Run 'main()'. Also, I tend to register the menus on all *.java files, whether it contains the main method or not. If current Java file does not contain the main method, then Java debugger will search for available main classes from the entire workspace.

testforstephen avatar Aug 10 '21 09:08 testforstephen

Since this issue is about name conventions, we should also consider the case of name conflicts between multiple extensions. How users can easily distinguish between multiple extensions when they contribute run/debug commands for the same language?

For example, Code Runner extension also supports the Run Java feature. If the user has both Code Runner and Java Debugger extensions installed, multiple Run java menus will appear in the drop-down menu. How do users know which one they should use? Automatically append the extension name to the menu name?

// Invite @formulahendry (author of code runner) for discussion.

testforstephen avatar Aug 12 '21 09:08 testforstephen

@testforstephen good point! Today the commands are only separated by a separator line in the dropdown menu. Our assumption was that only a small number of contributed commands will be visible at the same time (if they are sufficiently specific). Of course Code Runner is an exception (by design) to this...

weinand avatar Aug 12 '21 10:08 weinand

From our user study, we found installing both Code Runner and Java Debugger is not rare among Java users. That's the reason we opened https://github.com/microsoft/vscode/issues/114123 to discuss a solution to solve the conflicts.

Since Code Runner and Java Debugger have somewhat different "Run" behavior, users may not be able to run Java file if they do not select the correct "Run" menu.

  • Code Runner - Run snippet (if there is code being selected), or current file (with no dependencies). It would fail to run if the code uses some dependencies other than JDK library.
  • Java Debugger - Run current Java file (supports dependencies). It's kind of run as Java application, because it could resolve dependencies from current Project system as well and add them to the classpath at startup.

It is necessary to provide some way for the user to distinguish between them, either by different icons or menu names. What do you think?

Here is the current menu. It seems to express a different meaning with “Run Code” and "Run Java". Not sure whether users still understand the difference if it was changed to "Run Code" and "Run Main". image

testforstephen avatar Aug 13 '21 04:08 testforstephen