2 Replies Last post: Aug 12, 2014 6:59 PM by Mark Vedder  
Guest
Currently Being Moderated

Aug 11, 2014 11:43 PM

auto case

I hope someone will tell me this already exists

 

I would like it if when I type  

 

switch ( someenum )

 

with a keystroke or two IntelliJ would list all the possible enums

each labelled with case xxx:

 

-


 

Lets say there are 7 enums. I specified 5 and left out two.

 

I would like it if IntelliJ would generate

 

default:

case missing1:

case missing2:

 

so that all cases are explicitly dealt with, even if default logic

handles them. I want some help catching errors where I forgot to

specify one of the options.

 

 

--

Roedy Green Canadian Mind Products http://mindprod.com

The art of strongly-typed language design is largely arranging

that errors are automatically detected as soon as possible

in the compose, compile, run cycle.

 

Mark Vedder Apprentice 1,017 posts since
Dec 10, 2003
Currently Being Moderated
Aug 12, 2014 6:59 PM in response to: Roedy Green
Re: auto case

Guest wrote:

switch ( someenum )

 

with a keystroke or two IntelliJ would list all the possible enums

each labelled with case xxx:

 

 

Using auto complete (Ctrl+Space) after typing the case keyword will allow you to list and add an enum individually. If you want to complete all, type the switch (enumVar) line, hit enter, then open the Intention Actions menu (Alt+Enter) and select "Create missing 'switch' branches".

 

In general, if you want or think some sort of auto-complete / auto-generate would be nice somewhere when coding, open the quick-fix/intentions actions menu (Alt+Enter) and see if what you want is there. You'd be surprised how often it is. (Sometimes you may need to try it with your cursor in different places).

More Like This

  • Retrieving data ...