简体   繁体   English

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

[英]How to use selectors in /set truncation command in jshell?

I am using jshell and want to truncate the very big message displayed on jshell console. 我正在使用jshell并希望截断jshell控制台上显示的非常大的消息。

For this, i got the /set truncate command which says: 为此,我得到了/ 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. 使用/ set truncation命令设置为值显示的最大长度。 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

Can anybody please suggest the use cases of the case selectors or the action selectors?? 任何人都可以建议案例选择器或动作选择器的用例??

want to truncate the very big message displayed on jshell console. 想要截断jshell控制台上显示的非常大的消息。

This relies on what type of message do you want to truncate. 这取决于您要截断的消息类型 The case selector in which shall help you decide the type and action selector would help you decide when to do so. 案例选择器将帮助您确定类型和操作选择器,以帮助您决定何时执行此操作。 eg adding snippets, modifying etc. 例如,添加片段,修改等

How to use selectors in /set truncation command in jshell? 如何在jshell中的/ set truncation命令中使用选择器?

The examples from the same documentation lists out these nicely: 同一文档中的示例很好地列出了这些:

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

suggest the use cases of the case selectors or the action selectors?? 建议案例选择器或动作选择器的用例??

The documentation for defining a feedback mode # Set truncation section : 定义反馈模式的文档#Set截断部分:

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"`

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM