IntelliJ: generate a switch enclosure

Is there a way to generate a switch case for a given variable in IntelliJ?

Ctrl + space, and also Ctrl + J do not produce results.

+58
java intellij-idea
Sep 19
source share
2 answers

For enumeration variables, type switch (myEnumVar) and press Alt + Enter . Smart completion prompts: Create missing 'switch' branches

Crazy Coder provided the following screenshot showing how to enable the Create Enum Switch Branches setting.

Intention: Create Enum Switch Branches

See YouTrack issue 6374 .

+106
Sep 19
source share

Follow these steps: https://confluence.jetbrains.com/display/PYH/Creating+and+applying+live+templates+(code+snippets)

for context, use JAVA and the code for the switch-case statement:

 switch($switchVar$) { case $value$: $END$ break; default: break; } 

Do the same for try-catch;)

 try { $END$ } catch(Exception e) {e.printStackTrace();} 

I like the template function in intellij and use a lot.

+7
Dec 27 '14 at 16:37
source share



All Articles