I want to use ButterKnife for Android. I need to annotate some fields based on some expressions that are located elsewhere in the code. I have a 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() { ... ... }
As a result, the expression disappears, and the field is annotated based on the old expression.
Is it possible to perform such a search and replace in IntelliJ structural replacement? It seems that he does not gracefully handle the case when the lines of interest are not adjacent and are in different places structurally. I tried to base it on a class template and used $ Statement $ (0-unlimited occurrences), but this did not work for me.
I realized that it is relatively easy to use with regular expressions, which is much simpler than searching for IntelliJ's structural search for ball games, but I like to study my tools, so I would like to know if this is possible.
source share