Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

intellij have introduce constant be private not public

In Intellij IDEA 11.1.2, when using the refactor shortcut to Introduce a Constant, it always makes public static final constant, whereas I generally prefer to default to private. In older versions of Intellij, I'm pretty sure that I had the option of setting private as the default. Does anyone know if there still exists an option to default to private for the Introduce Constant refactor option rather than having to afterwards go to the declaration and edit the public to private? Thanks

like image 980
Kirby Avatar asked Jun 04 '12 18:06

Kirby


People also ask

How do I change the public class name in Intellij?

Press Shift+F6 or from the main menu, select Refactor | Rename. next to the highlighted element. You can press Tab to open the context menu and select the additional rename options. If you want to see the Rename dialog with more options, click the More options link or press Shift+F6 .

How do I introduce a local variable in Intellij?

Press Ctrl+Alt+V or from the main menu, select Refactor | Extract/Introduce | Variable. Select a name suggested in the popup or type your own and press Enter . that you can use to configure more options.

How do I move a method from one class to another in Intellij?

Open your class in the editor, place a caret at the static method you want to move and press F6 . In the Move Members dialog specify the following options: In the Members to be moved to another class (static only) field, select the checkboxes next to the methods that you want to move to another class.


2 Answers

ah, never mind, I see. You have to press command-alt-C again to get the old dialog. Grrr. The short cut is getting longer....

like image 124
Kirby Avatar answered Oct 11 '22 22:10

Kirby


I had the same problem and solved it (idea 12).

To introduce private constants by default do the following:

  • Disable in-place mode (File -> Settings -> Editor -> General -> uncheck "Enable in-place mode")
  • Try to introduce something (You will see a refactor dialog). Select "private" in that dialog
  • Enable in-place mode
  • Enjoy private constants
like image 20
Gregory Kalabin Avatar answered Oct 11 '22 23:10

Gregory Kalabin