Arrayof to array literal refactor and code formatting


#1

I have a Dagger2 component and was defining the list of modules, like the following:

@Singleton
@Component(modules = arrayOf(AndroidSupportInjectionModule::class, AppModule::class,
        NetModule::class,
        co.uk.me.manage.presentation.main.module.Module::class,
        co.uk.me.manage.presentation.comic.module.Module::class))
interface AppComponent {
     fun inject(app: App)
}

I noticed when taking a look at 1.2.0 beta 2, the code has an intent (yellow underline) on the arrayOf that tells me: ‘arrayOf can be replaced with array literal.’ So I execute that. Now my code ends up looking like this:

@Singleton
@Component(modules = [(AndroidSupportInjectionModule::class), (AppModule::class), (NetModule::class), (co.uk.me.manage.presentation.main.module.Module::class), (co.uk.me.manage.presentation.comic.module.Module::class)])
interface AppComponent {
    fun inject(app: App)
}

The array literal code ends up all on one line. I’d prefer this to preserve the code formatting. So, I try adding some newlines, and then try formatting my code. This ends up with the following:

@Singleton
@Component(modules = [(AndroidSupportInjectionModule::class),
(AppModule::class),
(NetModule::class),
(co.uk.me.manage.presentation.main.module.Module::class),
(co.uk.me.manage.presentation.comic.module.Module::class)])
interface AppComponent {
    fun inject(app: App)
}

My expectation is that when hitting ‘code format’ on this example, it would indent the array literal arguments to the same depth as the array literal opening square bracket. Or at the very least, indent one level deeper than the @Component annotation.

Thanks for listening.