suusan2go / kotlin-fill-class

Intellij plugin that provides intention action for empty constructor
https://plugins.jetbrains.com/plugin/10942-kotlin-fill-class
MIT License
268 stars 31 forks source link

Fill enum value #122

Closed phangji closed 1 year ago

phangji commented 1 year ago

It would be nice to fill with enum. I've seen that enums are intentionally excluded in code. but I think working with enum would be very useful.

Discussion Points

type.memberScope.getVariableNames() returns enum members like HAPPY, SAD, ANGRY but also returns description(parameter), auto generated variables like name, ordinal.

To identify exclusively enum members from them, (1) To filter starting with upper case variable (using convention; enum member name should start with capital) (2) To filter not generated variables(name, ordinal), parameter(in this case - description) (3) just leave it to luck to choose enum members on runtime.

I tried (2) but the code will be too complicated. It's hard to identify parameter from enum members and others. I think (1) solution would be reasonable in this situation. I want to hear your opinion. @suusan2go @oboenikui

(This draft is applied (1) case)

oboenikui commented 1 year ago

@phangji Thank you for your contribution! From a maintainer's point of view, I would prefer (2). In my experience, I need to consider cases where variables generated by code generation tools may be in lower case. Also, we must treat as a bug the case of a fill that begins with an uppercase letter in other values, such as internal classes. I have found a way to ensure that only the enum entry is retrieved, so can I add commits to use that method? In this case, it can be filled with the first enum entry.

oboenikui commented 1 year ago

@phangji I haven't received a response for a week, so I will merge with the method I proposed. Thank you for the Pull Request.