我正在使用jshell并希望截断jshell控制台上显示的非常大的消息。
为此,我得到了/ set truncate命令,其中包含:
如果值太长,则在显示时会截断它们。使用/ set 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
有人可以建议案例选择器或动作选择器的用例吗?
答案 0 :(得分:1)
想要截断jshell控制台上显示的非常大的消息。
这取决于您要截断的类型的消息。 案例 选择器可帮助您确定类型, 操作 选择器可帮助您决定何时执行此操作。例如添加片段,修改等。
如何在jshell中使用/ set truncation命令中的选择器?
同一文档中的示例很好地列出了这些:
/set truncation mymode 45 expression
/set truncation mymode 0 varinit-modified,replaced
建议案例选择器或动作选择器的用例??
defining a feedback mode#设置截断部分的文档:
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
$2 ==> "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi ... yzabcdefghijklmnopqrstuvwxyzabcd"
# we can see the overriden truncation value in the next statement
mymode: big
big ==> "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl...jklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd"`