I want to use ButterKnife for Android. I need to annotate some fields based on some expressions which are elsewhere in code. I have code like this
private String myField;
...
public myClassConstructor() {
...
myField = res.getString(R.string.my_string_id);
...
}
I want this
@BindString(R.string.my_string_id);
String myField;
...
public myClassConstructor() {
...
...
}
In the result the expression is gone, and the field is annotated based on the old expression.
Is it possible to do this kind of search and replace in IntelliJ's structural replace? It seems it does not gracefully handle the case when the lines of interest are not adjacent and are in different locations structurally. I tried basing it on class template, and used $Statement$ (0-unbounded occurrences) but it did not work for me.
I realized its actually relatively simple to do with regular expressions, certainly much simpler than getting IntelliJ structural search to play ball, but I like to learn my tools, so I would still like to know if this is possible.