eclipse-archived / ceylon.formatter

A formatter for the Ceylon programming language, written in Ceylon.
Apache License 2.0
14 stars 11 forks source link

Support `else if` in switch #121

Closed lucaswerkmeister closed 8 years ago

lucaswerkmeister commented 8 years ago

This is now allowed:

shared void run() {
    switch (process.arguments.size)
    case (0) { print("no arguments"); }
    else if (process.arguments.first?.equals("foo") else false) { print("first argument is foo"); }
    else if (process.arguments.first?.equals("bar") else false) { print("first argument is bar"); }
    else { print("first argument is neither foo nor bar"); }
}

The formatter currently turns it into this:

shared void run() {
    switch (process.arguments.size)
    case (0) { print("no arguments"); }
    else if (process.arguments.first?.equals("foo") else false) { print("first argument is foo"); } else if (process.arguments.first?.equals("bar") else false) { print("first argument is bar"); } else { print("first argument is neither foo nor bar"); }
}

(I also reject any responsibility for a delayed ceylon.formatter release if @gavinking thinks it’s a good idea to add new syntax two days before release without telling anyone. FFS.)