[英]IntelliJ Automatically create private fields / methods like in Visual Studio?
In Visual Studio 2012 I can type something like aString = ''
. 在Visual Studio 2012中,我可以输入类似
aString = ''
。 This variable hasn't been declared as yet and by pressing ctrl + .
尚未按
ctrl + .
声明此变量ctrl + .
the IDE is wonderful enough to create a private datamenber named aString of type String. IDE足以创建一个名为String的aString私有数据员。
Is there a feature that mirrors this in IntelliJ? IntelliJ中是否有反映此功能的功能?
I found an option for auto inserting methods on https://www.jetbrains.com/idea/features/code_assistance.html but couldn't find anything relating to private fields. 我在https://www.jetbrains.com/idea/features/code_assistance.html上找到了一种用于自动插入方法的选项,但找不到与私有字段相关的任何内容。
I don't have access to the IDE at the moment before anyone suggests the obvious :) 在没有人提出明显建议之前,我目前无法访问IDE :)
Absolutely. 绝对。
If you write aString = "" and you click alt-enter you'll get an option to create a field (private by default) for it along with several other options. 如果编写aString =“”,然后单击alt-enter,您将获得一个选项来为其创建一个字段(默认情况下为私有),以及其他几个选项。
Another way of doing it is by first typing only ""
and then .var
. 另一种方法是先输入
""
,然后输入.var
。
This is called Postfix Code Completion and is very useful. 这称为“ 后缀代码完成” ,非常有用。 There are lots of other completions other than the
.var
one. 除了
.var
以外,还有许多其他.var
全。 I often use the .cast
postfix completion for example. 例如,我经常使用
.cast
后缀.cast
。
Use it like this: 像这样使用它:
Then you just start typing the name of your variable: 然后,您只需开始输入变量的名称:
And finally there it is your complete line: 最后是您的完整行:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.