简体   繁体   English

如何配置 Eclipse / STS 自动完成以建议新语句的构造函数参数名称?

[英]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.

相关问题 如何配置Grails应用程序以与STS / Eclipse上的Hibernate Tools一起使用? - How to configure my Grails app to be used with Hibernate Tools on STS/Eclipse? 如何让Eclipse intellisense自动完成成员名称? - How to have Eclipse intellisense autocomplete member names? Eclipse / STS将“新”自动更正为“ newEmail” - Eclipse/STS auto-correcting “new” as “newEmail” 每次启动服务器时如何停止Eclipse(STS)创建新的运行时配置 - How do I stop Eclipse (STS) from creating a new runtime configuration every time I start a server 如何使用 STS\\Eclipse 正确创建具有 Maven 结构的新 Spring MVC 项目? - How can I correctly create a new Spring MVC project with Maven structure using STS\Eclipse? 如何在STS(Eclipse)中生成黄瓜特征的步骤? - How to generate steps of cucumber features in STS (Eclipse)? 没有源的Eclipse中的自动完成参数名称 - Autocomplete Parameter names in Eclipse Without Source 如何在eclipse中配置“将参数分配给新字段”quickfix的行为? - How to configure behavior of the “assign parameter to new field” quickfix in eclipse? Eclipse如何为=禁用自动完成功能 - Eclipse How to Disable Autocomplete For = 如何配置Eclipse以仅向我显示自动完成投标中类型的直接成员? - How do I have to configure Eclipse to show me only direct members of a type in an autocomplete proposal?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM