Code Actions
Code Actions are used to provide automatic refactoring or rewriting of your current code in order to enhance its readability or save users' time.
In Visual Studio Code, to use them you can click on the yellow light bulb appearing on your code, near the cursor and then, to pick the desired action to perform on the code. Alternatively, you can use the editor.action.quickFix
shortcut.
For other editors this should also be available via specified shortcut.
Here is a list of the code actions supported by Metals.
Convert To Named Arguments
This code action adds the name to parameters passed to a method call or a class constructor.
Create Companion Object
If you have a trait
or a class
definition, you can invoke this code action to create its companion object.
Create New Symbol
Used for creating a definition for a symbol which is used in your code, but not defined anywhere.