IntelliJ: Generate switch case

By | August 8, 2019

Question

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.

Solution

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.

Intention: Create Enum Switch Branches

See YouTrack issue 6374.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *