Intellij代码完成,用于局部变量对象的所有设置器/获取器方法 [英] Intellij Code Completion for all setter/getter methods of local variable object

查看:74
本文介绍了Intellij代码完成,用于局部变量对象的所有设置器/获取器方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确实尝试搜索此内容,但是说实话,实际搜索的术语在逃避我。一个小代码段,然后是问题。

I did try searching for this, but honestly the terms to actually search are escaping me. A small code snippet followed by the question.

Public class Person {

   String firstName;
   String lastName;

   public void setFirstName(String firstName) {
      this.firstName = firstName;
   }

   public String getFirstName() {
      return firstName;
   }
   ...
}

另一个使用此person对象的对象,我希望能够扩展Intellij中的所有setter方法。

In another object that uses this person object I would like to be able to expand all the setters methods in Intellij.

public class PersonAssembler { 
    public static Person assemblePerson(SomeOtherObject someOtherObject) {

    Person person = new Person;

    //intellj would provide this below.
    person.setFirstName();
    person.setLastName();
    //end of what intellj provides.

    return person;
}

这甚至可能吗?我查看了键盘快捷键等内容。我使用intellij已有一段时间,因此想知道是否有人对此有所了解。

Is this even possible? I have looked through the keyboard short cuts, etc. I have been using intellij for a while, so just wondered if anyone had some insight on this.

我希望有列编辑模式,然后是代码完成功能,也许还有一个shift +向下箭头来选择多个完成功能,但是没有运气。这不足为奇。我讨厌不得不在GUI中编写该代码。

I was hoping for column edit mode, then code completion and perhaps a shift+down arrow to select multiple completions, but no luck. Which is not surprising. I would hate to have to write that in the GUI.

编辑:我添加了一些说明,并且老实忘了这个问题。如果仔细阅读,答案与实际问题无关。我不是说生成上下文菜单。

I added some clarification and honestly forgot about this question. The answers have nothing to do with the actual question if read carefully. I am not speaking of the Generate context menu.

推荐答案

在您的项目中,右键单击键入屏幕上的任意位置,然后单击生成...,然后是 Getter and Setter。然后,按住 CTRL 并单击要为其创建吸气剂和吸气剂的字段,然后单击确定。

In your project, right-click anywhere on the typing screen, and click 'Generate...' and then 'Getter and Setter'. Then, hold down CTRL and click on the fields you wish to create getters and setters for, then click on 'OK'.

这篇关于Intellij代码完成,用于局部变量对象的所有设置器/获取器方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆