JShell: three small proposal/feedback
Robert Field
robert.field at oracle.com
Mon Apr 4 16:05:26 UTC 2016
Thank you Yuji!
Comments inline.
On 04/04/16 03:33, KUBOTA Yuji wrote:
> Hi REPL team,
>
> I enjoyed debugging by using very good REPL - JShell.
> And I would like to add following (small) changes for usability.
>
> 1. /edit display warn instead of quit by HeadlessException in headless mode
>
> Unfortunately, I did not think the default editor uses swing, so I got
> HeadlessException when I used /edit on a headless server, then
> my working log has gone. So I want that JShell warn instead of
> suddenly quit, as [1].
That would be good.
>
> 2. /-n return the available range rather than calculated "n"
>
> Just to avoid small confusion as below.
>
> Example:
> -> /-9
> | Cannot find snippet 0 ( - current implementation)
> | Cannot find snippet, select <n> between 1 - 8 ( - proposal [2])
How would this be useful to you? I'm thinking there might be a more
intuitive approach.
>
> 3. Implement /show command to confirm the current configuration
>
> We can set configuration, but cannot check current configuration
> except defined feedback modes by /help /set feedback.
> Should we provide /show command for easy check as below?
>
> Example for feedback mode:
> -> /set newmode test
> | Created new feedback mode: test
>
> -> /show feedback
> | Currently feedback mode: normal
> | All defined feedback mode: normal, test, off
Indeed, some kind of query for configuration is needed. However start
can be big (though that can be saved), and format can be huge. How
would prompt be displayed?
>
>
> If they accepted, I want to file them to JBS and to upload webrev when ready.
> note: I'm jdk9 author, not committer.
Certainly file the first one. I'm about to push internationalization of
the JShell, so that will change anything with output.
Let's kick the other two around a bit more.
Thanks,
Robert
>
> Thanks!
> Yuji
>
> [1]: patch for /edit
> diff --git a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java
> b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java
> --- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java
> +++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java
> @@ -1523,7 +1585,11 @@
> Consumer<String> saveHandler = new SaveHandler(src, srcSet);
> Consumer<String> errorHandler = s -> hard("Edit Error: %s", s);
> if (editor == null) {
> - EditPad.edit(errorHandler, src, saveHandler);
> + try {
> + EditPad.edit(errorHandler, src, saveHandler);
> + } catch (HeadlessException ex) {
> + hard("Cannot launch editor in headless mode. Try /set
> editor to use external editor.");
> + }
> } else {
> ExternalEditor.edit(editor, errorHandler, src, saveHandler, input);
> }
>
> [2]: patch for /-n
> diff --git a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java
> b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java
> --- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java
> +++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java
> @@ -1777,7 +1843,7 @@
> if (index >= 0 && index < keys.size()) {
> rerunSnippet(keys.get(index));
> } else {
> - hard("Cannot find snippet %d", index + 1);
> + hard("Cannot find snippet, select <n> between 1 - %d",
> keys.size());
> return false;
> }
> return true;
More information about the kulla-dev
mailing list