Reputation: 2685
Is there really no way to generate a switch case for a given variable in IntelliJ?
Ctrl+Space as well as Ctrl+J yield no results.
Upvotes: 90
Views: 52636
Reputation: 1382
Follow the steps in the manual…
For the context, use JAVA and the code for a switch - case Statement would be:
switch($switchVar$) {
case $value$:
$END$
break;
default:
break;
}
Do the same for try - catch ;)
try {
$END$
} catch(Exception e) {e.printStackTrace();}
I love the template function in intellij and use it a lot.
Upvotes: 15
Reputation: 24134
For enum variables, enter switch (myEnumVar)
and press Alt+Enter. Smart completion will suggest: Create missing 'switch' branches
Crazy Coder provided the following screenshot showing how to enable the Create Enum Switch Branches intention.
See YouTrack issue 6374.
Upvotes: 169