Creates a constant from a literal. This Code Provider is useful when you need to use a single value multiple times.
Available when the caret is on a literal.
Place the caret on a literal.
Hit Ctrl + . or Ctrl + ~ to invoke the Code Actions Menu.
Use the mouse to select Declare Constant from the menu and press Enter. The red target picker marker appears. It allows you to choose the place where the generated code can be inserted.
Use the Up Arrow and Down Arrow keys to move the target picker.
Press Enter to generate a code in the selected place.
After execution, the Code Provider creates a constant of the corresponding type and assigns a literal value to it.
The following screencast shows the described steps in action.
You can configure the Target Picker on the Editor | All Languages | Code Actions | Target Picker options page.