The following Code Style setting is available:
Preferences | Editor | Code Style | Java | Wrapping and Braces | Keep when reformatting | Simple methods in one line
Enable it to keep the formatting of any methods formatted in your desired style.
Unfortunately there is no code style setting to format methods with a single line body on a single line. But there is the workaround of using Structural Search & Replace for this formatting using a template like this:
<replaceConfiguration name="constructors & methods" text="$ReturnType$ $Method$($ParameterType$ $Parameter$) { $st$; }" recursive="false" caseInsensitive="true" type="JAVA" pattern_context="member" reformatAccordingToStyle="true" shortenFQN="true" replacement="$ReturnType$ $Method$($ParameterType$ $Parameter$) { $st$; }">
<constraint name="__context__" within="" contains="" />
<constraint name="ReturnType" minCount="0" within="" contains="" />
<constraint name="Method" within="" contains="" />
<constraint name="ParameterType" within="" contains="" />
<constraint name="Parameter" minCount="0" maxCount="2147483647" within="" contains="" />
<constraint name="st" within="" contains="" />
</replaceConfiguration>
Copy the template above and open Edit | Find | Replace Structurally
. Next import the template by invoking Import Template from Clipboard
(under the cog menu) and click Find.
This will find all methods with a single line body and replace them with the same method formatted on one line.