jphalip / ideavim-switch

MIT License
1 stars 0 forks source link

Support iteration over enum values #1

Open lippfi opened 3 days ago

lippfi commented 3 days ago

I've been working on a plugin-like switch for some time. It's a pleasure that someone has done it - thank you. If you could support iterating over enum values, it would be super cool. I mean replacing Month.JANUARY with Month.FEBRUARY and so on. It would allow creating some clever mappings and filling when/switch branches utilizing Vim macro.

jphalip commented 2 days ago

That's an interesting use case. I assume this would require relying on language plugins (e.g. https://plugins.jetbrains.com/plugin/6954-kotlin) to identify enums and their values, right? Let me look into it.

jphalip commented 2 days ago

I just took a quick & dirty stab at it (see this branch: https://github.com/jphalip/ideavim-switch/tree/enums) and got it to work with this Kotlin example:

enum class Direction {
    NORTH, SOUTH, EAST, WEST
}

val value = Direction.SOUTH

Would you like to take it for a spin?