Re: String literals into constants automagically?
Mark Smith wrote:
> I am using netbeans [sic]. One feature that I love is the insert code
> feature, for automatically making getters and setters it has saved me
> hours of braindead tedious work.
>
> I am looking at some code now that has gardually evolved into a mess
> and I think it is time to tidy it up. It does a lot of string
> comparisons. There are over 200 string literals in the main class! It
> strikes me as another braindead task that could be almost completely
> done by a computer.
NetBeans and Eclipse (and its derivatives) have this feature.
> Is there a feature in netbeans [sic] (or any ide [sic]) that can extract String
> literals from a selection and replace them with centrally defined
> constants?
As John B. Matthews said of NetBeans:
> See if "Introduce Constant" would be apropos:
NetBeans:
Menu: "Ref_a_ctor / Introduce _C_onstant"
Eclipse:
Menu: "Refac_t_or / Extr_a_ct Constant..."
Both IDEs will refactor all instances of the same constant, but you must have
a constant selected for the feature to know what to extract. Both give you
the choice of access qualifier. Both preselect a suggested constant
identifier that you can override.
--
Lew
|