https://kotlinlang.org logo
Title
j

Jukka Siivonen

05/21/2019, 9:07 AM
Why does not IDEA allow (gives warnings) formatting builder chains like this?
http
    .antMatcher("/api/**")
    .cors()
        .and()
    .exceptionHandling()
        .authenticationEntryPoint(UnauthorizedAuthenticationEntryPoint())
        .and()
    .sessionManagement()
        .sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED)
        .and()
OK the snippet is not very clear here but the point is without any indents in builder chain they are annoying to read
s

Stephan Schroeder

05/21/2019, 9:12 AM
i guess because it doesn’t want to enforce a specific format. But you can use CTRL+ALT+L to fix it.
j

Jukka Siivonen

05/21/2019, 9:17 AM
CTRL+ALT+L makes it the way I don't like it to be
but I can't find IDEA formatter setting which causes the warnings in the first case
g

gildor

05/21/2019, 9:40 AM
Probably this is setting of Editor -> Code Style -> Warning
c

Czar

05/21/2019, 10:22 AM
When doing custom formatting like that, surround the code with @formatter:off/on comments:
//@formatter:off
	val a = 0
		val b = 1
	val c = 2
			val d = 3
	//@formatter:on
This will prevent IntelliJ from reformatting it, given that you have formatter markers enabled in
File | Settings | Editor | Code Style
2
🤯 1