简体   繁体   English

自动生成默认和字段构造函数的 eclipse 快捷方式是什么?

[英]What is the eclipse shortcut for auto-generating a default and field constructor?

I had a look at: Eclipse-Shortcuts , but I found nothing for generating a constructor.我看了一下: Eclipse-Shortcuts ,但我没有找到任何生成构造函数的信息。

Whats the shortcut for generating a standard constructor?生成标准构造函数的快捷方式是什么?

Type the first letter of your class, then press Ctrl + Space , Eclipse will list suggestions within a combobox.输入班级的第一个字母,然后按Ctrl + Space ,Eclipse 将在组合框中列出建议。 The topmost suggestion is the default constructor.最重要的建议是默认构造函数。 Press Enter , it will be done.Enter ,它会完成。 (I'm using Eclipse Juno and it works.) (我正在使用 Eclipse Juno 并且它有效。)

Alt + Shift + s and then o opens the Generate Constructor using Fields dialog. Alt + Shift + s然后o打开“ Generate Constructor using Fields对话框。

Goto Source ---> Generate constructor using Fields

Under Source Title bar, select the Generate constructor using Fields option.在 Source Title 栏下,选择 Generate constructor using Fields 选项。

Or要么

Ctrl+Space which displays the various suggestions possible, from there you can go for the default contructor. Ctrl+Space显示各种可能的建议,从那里你可以找到默认的构造函数。

Ways to Generate default Constructor -生成默认构造函数的方法 -
1) Press Ctl + Space 1) 按Ctl + Space

Ways to Generate field Constructor -生成字段构造函数的方法 -
1) Press Alt + Shift + S + O 1) 按Alt + Shift + S + O
2) Right click -> Source -> Generate Constructor using field 2)右击->Source->Generate Constructor using field
3) Go to Source menu -> Generate Constructor using field 3)转到源菜单- >使用字段生成构造函数
4) Go to Windows menu -> Preferences -> General -> Keys (Write Generate Constructor using field on text field) 4) 转到Windows 菜单-> Preferences -> General -> Keys (Write Generate Constructor using field on text field)

When you hit CTRL-SPACE inside your class definition, you will see a drop down.当您在类定义中按下CTRL-SPACE时,您会看到一个下拉菜单。 First option is your Constructor.第一个选项是您的构造函数。

For Mac Users it is对于 Mac 用户,它是

Option + Command(⌘) + S or Option + Command(⌘) + S

Command(⌘) + Option + S will open the pop up. Command(⌘) + Option + S 将打开弹出窗口。

Or you could type Ctrl + 3 and type GCUF, what means.或者您可以键入 Ctrl + 3 并键入 GCUF,这是什么意思。 Generate Constructor Using Field.使用字段生成构造函数。 Do almost the same to generate getters and setters: Type Ctrl + 3 and type GGAS, what means, Generate Getters And Setters执行几乎相同的操作来生成 getter 和 setter:键入 Ctrl + 3 并键入 GGAS,什么意思,Generate Getters And Setters

There are several ways you can follow.您可以采用多种方法。

  1. easiest:- put the cursor inside the class and Ctrl + Space then click Enter (because the first option of the list given by ctrl+ space is contructor)最简单:- 将光标放在类中,然后按Ctrl + Space然后单击Enter (因为 ctrl + space 给出的列表的第一个选项是构造函数)
  2. Ctrl + 3 type "constr". Ctrl + 3输入“constr”。 hit Enter .点击Enter you'll get the dialog box of generate constructor.你会得到生成构造函数的对话框。 here you can select whether you want the parameter or not.在这里您可以选择是否需要参数。 select and hit Enter选择并按Enter
  3. Click Alt + Shift + s then click o You will get the same dialog box mentioned in the above (2).点击Alt + Shift + s然后点击o你会得到与上面(2)中提到的相同的对话框。 Do your selection.做你的选择。 hit Enter按回车

I think CTRL + 3 is great.我认为 CTRL + 3 很棒。

GCFS - generate constructors from a superclass. GCFS - 从超类生成构造函数。 GCUF - generate constructor using fields. GCUF - 使用字段生成构造函数。 GGAS - generate getters and setters. GGAS - 生成 getter 和 setter。

I think shortcut key to generate Constructors is outdated.我认为生成构造函数的快捷键已经过时了。 Alt+Shift+s and then press A opens the Generate Constructor using Fields dialog Alt+Shift+s然后press A打开“ Generate Constructor using Fields对话框

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

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