如何在 jshell 的 /set truncation 命令中使用选择器?

How to use selectors in /set truncation command in jshell?

我正在使用 jshell 并想截断显示在 jshell 控制台上的非常大的消息。

为此,我得到了 /set truncate 命令,它说:

If the values are too long, then they are truncated when displayed. Use the /set truncation command to set the maximum length shown for a value. If no settings are entered with the command, then the current setting is displayed.

Below are the relevant selector kinds for truncation.

|  
|  The case selector kind describes the kind of snippet.  The values are:
|   vardecl    -- variable declaration without init
|   varinit    -- variable declaration with init
|   expression -- expression -- note: {name}==scratch-variable-name
|   varvalue   -- variable value expression
|   assignment -- assign variable
|  The action selector kind describes what happened to the snippet.  The values are:
|   added     -- snippet has been added
|   modified  -- an existing snippet has been modified
|   replaced  -- an existing snippet has been replaced with a new snippet

任何人都可以建议案例选择器或动作选择器的用例吗??

want to truncate the very big message displayed on jshell console.

这取决于您想截断消息的类型case 选择器将帮助您决定类型和 action 选择器将帮助您决定何时这样做。例如添加片段、修改等

How to use selectors in /set truncation command in jshell?

同一文档中的示例很好地列出了这些:

/set truncation mymode 45 expression
/set truncation mymode 0 varinit-modified,replaced

suggest the use cases of the case selectors or the action selectors??

定义的文档 一个反馈模式 # 设置截断 section :

mymode: /set truncation mymode 100

mymode: /set truncation mymode 300 varvalue

# default truncation
mymode: String big = IntStream.range(0,1200).mapToObj(n -> "" + (char) ('a' + n % 26)).collect(Collectors.joining())
big ==> "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv ... fghijklmnopqrstuvwxyzabcd"

# default truncation
mymode: big + big
 ==> "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi ... yzabcdefghijklmnopqrstuvwxyzabcd"

# we can see the overriden truncation value in the next statement
mymode: big
big ==> "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl...jklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd"`