java - A simple way to create static imports for constants in existing code? -
If I have a constant bar in Fu, which I will use in class C. I have to write
< Previous> object o = Foo.BAR + "..."; To create a stable import to stabilize I can use Ctrl-Shift-M (with cursor on the bar) in Eclipse:
< Code> imported steady Fu .BAR; Object o = bar + "....";
I am currently updating the legacy code with thousands which I want to convert to static import. Ctrl-Shift-O / Organize import does not do this. Is there any such move that I miss?
EDIT: In fact, what I would prefer, is one way to tell Elyssee that I have to spell it on all instances in Ctrl-Shift-M, instead of just one example, this particular The square is placed in my cursor. (This is a legacy code, so it actually improves readability :))
EDIT: I've found that IntelliJ suggests doing this.
A careful note: Excessive use of static import can actually make your code less readable (iehhoo) It is related, especially if the constant name does not clearly indicate the square or enum.
So you are compelled to do what the reader is hoping that her IDE will tell her class (tell, say, a tool tip) or they will have to navigate to find out what it is . Printouts and code snippets are becoming less readable.
Honestly, I use less static imports for these reasons.
Comments
Post a Comment