Search code examples
android-studiointellij-ideakotlinextractconstants

Android Studio Kotlin: Extract as Constant


In IntelliJ-based IDEs like Android Studio, in Java source codes, there is an option to extract things as constants when possible (final static). It is in Refactor -> Extract -> Constant and is accessible via Ctrl+Alt+C.

But I can't find it for Kotlin source codes!

enter image description here


Note 1: I can do it manually as you can see about NUMBER in the above screenshot (by defining it as a const val in companion object).

Note 2: The reverse-action is accomplishable by IDE; it means you can inline NUMBER with Ctrl+Alt+N.


Solution

  • Unfortunately, this is a known missing feature for now. It's being tracked on the official issue tracker. You can vote for it there =)