How extract private static constant in Intellij Idea?
JavaIntellij IdeaRefactoringKeyboard ShortcutsConstantsJava Problem Overview
To extract constant I can use ctrl + alt + c, that "extraction" create public constant:
public static final String CONST = "123";
So I need manually type private. Is there a way to extract constant with private scope by default?
Java Solutions
Solution 1 - Java
Hit ctrl+alt+c twice (shows Extract Constant
dialog)
hit alt+v (set default Visibility
to Private
)
hit enter
Done :) The private scope is set default - so you can use constant extraction as before, to change default scope simply repeat steps above with choosing different scope.
Solution 2 - Java
Try this:
> If the Enable in place refactorings check box is cleared on the Editor > settings, the Extract Constant refactoring is performed by means of > the Extract Constant Dialog dialog box.
http://www.jetbrains.com/idea/webhelp/extract-constant.html
Extract Constant Dialog allows choose the appropriate scope of constant
Settings -> Editors -> Enable Place refactoring