Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable folding of `: Unit =` in scala procedures in Intellij IDEA?

In recent versions of Intellij IDEA, when writing a scala method which returns Unit(a.k.a. a procedure), IDEA will fold the : Unit = part, so that it displays like the so-called "procedure syntax". Here's what it looks like :

def myMethod(): Unit = {
  // do something
}

gets folded by default to :

def myMethod()  {
  // do something
}

I understand the point, since the procedure syntax is slated for deprecation but some people still like it, I guess it's a good compromise for them. However, for those of us who don't like the procedure syntax, I wasn't able to find a setting to disable that code folding by default. Preferences > Editor > Code folding does show some scala-specific settings for which code foldings should be collapsed by default, but the only one I have checked is "Shell comments (scala script)".

Does someone know how to disable this feature? Or is it currently impossible?

like image 417
Cyäegha Avatar asked Aug 27 '14 21:08

Cyäegha


People also ask

How to comment Scala code in IntelliJ?

Single-line comments in Java start with two forward slashes ( // ). To quickly add a line comment in IntelliJ IDEA, press ⌘ / on macOS or Ctrl + / on Windows and Linux.

How to convert Java code to Scala code?

Java-to-Scala code conversionCopy your Java code (expression, method, class) and paste it into a Scala file. IntelliJ IDEA displays the Convert the code from Java dialog suggesting a conversion. Click OK.

Can you Run Scala in IntelliJ?

Run Scala applicationsYou can run your Scala code through IntelliJ IDEA, use sbt shell, or use Scala worksheet for a quick code evaluation.


1 Answers

It's in Preferences -> code style -> Scala, then on the right there are two hidden tabs, go on other and there should be a check with Enforce procedural syntax for methods with Unit return type

enter image description here

For Intellij 14 the path is slightly different:

enter image description here

like image 191
Ende Neu Avatar answered Oct 04 '22 04:10

Ende Neu