Idea for plugin (maybe for InspectionGadgets)
When InspectionGadgets tell me that I have a magic number,
I would like to have the intention to replace the magic
number with the appropriate constant.
Let's say I have this code:
Putting the cursor on the first '10' in the Dimension call
and pressing Alt-Enter should present a list with the
options:
- Introduce Constant (same as existing refactoring)
- Use WIDTH (10)
- Use HEIGHT (10)
The choices in the list are those constants whose value
matches the number that is to be replaced.
Can it be done?
/Mikael
请先登录再写评论。
At present, no. The "Introduce Constant" refactoring isn't available in the Open API. I've got an open Tracker request for it (and a few other refactorings that would make good inspection quickfixes), but until JetBrains opens it I have no way to connect.
Sorry.
--Dave Griffith