History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEA-11228
Type: New Feature New Feature
Status: Waiting for Reply Waiting for Reply
Assignee: Anna Kozlova
Reporter: Dave Yost
Votes: 1
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
IDEA: Feedback

Refactor strings into enum members

Created: 25 Jan 07 04:42   Updated: Yesterday 19:06
Component/s: Refactoring

Build: 6,148
Severity: Low


 Description  « Hide
If you select multiple initialized string declarations, IDEA should offer an intention to make them all members of an enum.
static final String FOO = "foo";
static final String BAR = "bar";
  ...
  baz(FOO);

would become

enum Whatever { foo, bar };
  ...
  baz(Whatever.foo.name());

The intention dialog could also offer to push the use of the enum down into methods, so the code instead could become

  baz(Whatever.foo);


 All   Comments   Work Log   Change History      Sort Order:
Dave Yost - 12 May 07 11:19
I've made a web page that talks about this.
http://yost.com/computers/java/java-spaghetti/

Dave Yost - 05 Oct 08 21:55
Anything happening with this?

Anna Kozlova - 06 Oct 08 12:37
It is possible to move your constants to enum as enum constants. Is it a solution?
Thank you

Raffi Khatchadourian - 15 Oct 08 00:28
I have a working implementation of refactoring non-string (e.g., int, bool, short) constants to enums in Eclipse. However, it does not currently have a GUI. You're welcome to have a look at it: https://bugs.eclipse.org/bugs/show_bug.cgi?id=200152