[英]How to configure Eclipse / STS autocomplete to suggest constructor argument names for new statements?
My Eclipse/STS used to autocomplete a new
statement with argument names from the original class constructor.我的 Eclipse/STS 曾经使用原始 class 构造函数中的参数名称自动完成new
语句。 For example, let's suppose I have a Sale class like this:例如,假设我有一个这样的销售 class:
public class Sale {
private Integer month;
private Integer year;
private String seller;
private Integer items;
private Double total;
public Sale(Integer month, Integer year, String seller, Integer items, Double total) {
...
Then if I start writing a new
statement, the autocomplete used to suggest me a constructor call using argument names:然后,如果我开始编写new
语句,自动完成功能会建议我使用参数名称调用构造函数:
Sale sale = new Sale(month, year, seller, items, total);
However, recently, the autocomplete is suggesting null
, like this:但是,最近,自动完成建议null
,如下所示:
Sale sale = new Sale(null, null, null, null, null);
How to configure Eclipse / STS autocomplete to suggest constructor argument names for new statements?如何配置 Eclipse / STS 自动完成以建议新语句的构造函数参数名称?
There are two strategies that can be used by the editor to propose arguments for method or constructor calls:小编可以使用两种策略为方法或构造函数调用提出arguments:
best guessed arguments (this tries to find the best matching name in your scope that fits the type - but if there is no reference around in the scope where your new statement is, it inserts null
since the editor can't find a anything that is matching)最好的猜测是 arguments(这会尝试在您的 scope 中找到适合该类型的最佳匹配名称 - 但如果在您的新语句所在的 scope 中没有引用,它会插入null
,因为编辑器找不到任何是匹配)
parameter names (this inserts the names of the parameters, independent of what is available in the scope of the new statement, sounds like this is what you are looking for)参数名称(这会插入参数名称,与新语句的 scope 中可用的内容无关,听起来这就是您要查找的内容)
You can switch between both options in Preferences -> Java -> Editor -> Content Assist
and look for the choice below Fill method arguments and show guessed arguments
.您可以在Preferences -> Java -> Editor -> Content Assist
中的两个选项之间切换,并在Fill method arguments and show guessed arguments
下面寻找选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.