wosemg
Last Updated: February 25, 2016
·
444
· founddrama

Idea: smart about switch statements

Doing some Groovy development using IntelliJ IDEA? You might have noticed that it will mark any fall-throughs in your switch statements as a warning. This helpful, but it's annoying when you're doing it on purpose. But if you are doing it on purpose:

switch (item) {
  case 'thing1':
    doAThing()
    break
  case 'thing2':
    anotherThing()
    // intentional fall through
  default:
    lastThing()

If you have exactly that comment:

// intentional fall through

...as the last line of that case then Idea won't mark it as a warning.