IntelliJ Structural Search and Replacement Issues

Is there an easy way to capture types? I cannot do simple things, for example, to use variable expressions nearby, for example $mapType$$mapEnd$ , to do a simple replacement. Is there a reason for this? That is, if I have one expression, say .*\s*.*abc , and I break it into two variables,. .*\s* and .*abc , the expression does not match the text. What could be wrong?

 Example template: $var1$ = $impl$ Example second template: $var1$ = $type$$implEnd$ 

If $impl$ is a full regular expression, placing $type$ and $implEnd$ together with half the matching regular expression causes the patterns to not match. What could be wrong?

I am trying to do this conversion:

 List<String,Object> list = new ArrayList<String,Object>(); List<String,Object> list = Lists.newArrayList(); 

It is clear that I need to somehow capture the "Array", as well as only those types that have no arguments.

+2
source share
1 answer

An SSR corresponds to one or more language constructs for each variable; it will NOT write multiple variables ($ mapType $$ mapEnd $) to a type reference (or any language token). For type code

List<String> someName = new ArrayList<String>();

need to have a search template

List<$Type$> $variable$ = new $ListType$<$Type$>()

and replace it accordingly. For more complex generic expressions, you need to consider several typical variables such as Map<$Key$, $Value$> You can find this article useful (many specific examples of SSR patterns)

http://www.jetbrains.com/idea/documentation/ssr.html

+1
source

Source: https://habr.com/ru/post/1316214/


All Articles