-1

假设我有很多变量

String not_id, not_section, not_steet, not_sqTotal, not_sqLiving, not_sqKitchen, not_flat, not_floor, not_floors, not_text, user_phone1, user_phone2, user_contact, not_region, not_district, not_settle, not_price, not_photo, not_date, not_date_till, not_up, not_premium, not_status;

not_id= not_section= not_steet= not_sqTotal= not_sqLiving=
                not_sqKitchen= not_flat= not_floor= not_floors= not_text=
                user_phone1= user_phone2= user_contact= not_region= not_district=
                not_settle= not_price= not_photo= not_date= not_date_till= not_up=
                not_premium= not_status=region_title=district_title=settle_title=section_title="";

我需要使用 someFunction 更改它们的值

not_id = someFunction(not_id);

我怎样才能对所有变量执行这样的操作?

如果假设将变量名称更改为某个统一名称,请不要建议使用数组、列表和其他类型的集合。

我想知道在 java 本身、eclipse ide 或 eclipse 插件中是否存在这种可能性。

4

2 回答 2

1

这将导致代码有些难以维护,但您可以通过在第二条语句上使用正则表达式搜索和替换来轻松完成,将“var_name =”替换为“var_name = someFunction(var_name);”。

查找:([^=])+=

替换为:\1 = someFunction(\1);

于 2013-04-15T14:57:09.277 回答
1

someFunctionjava方法吗?还是一些简单的变压器正在从not_([a-z])(\w*)变为not[A-Z]\2?如果您只更改变量名称,请使用 eclipse 的出色重构重命名绑定到Ctrl+Shift+R它可以更改所有出现考虑范围规则

于 2013-04-15T15:03:44.270 回答