We'd like to search for compile time constants and constant expressions - Strings and primitive values. As far as I can tell, this is not possible?
The motivation is that we have found several occurences of Integer.parseInt("0"), String.valueOf(SOMECONSTANT)
and
stringBuffer.append("select ");
stringBuffer.append(USER_COLUMNNAME);
stringBuffer.append(" from ");
stringBuffer.append(TABLENAME);
We'd like to find all of them.
A long term solution would be to have inspections, but in the short term, we would just like to be able to search and replace for ourselves. But we can only search for Integer.parseInt("$str$") and will not find e.g. Integer.parseInt(MYCONSTANT+"0").
Or we can search/replace for
$stringBuffer$.append("$str1"); $stringBuffer$.append($CONSTANT$)
with
$stringBuffer$.append("$str1"+$CONSTANT$)
- but that depends on naming conventions, and it will not be able to recurse to turn the larger sample into
stringBuffer.append("select "USER_COLUMNNAME" from "+TABLENAME);