Domanda

Is there an easy way to capture types? I can't seem to do basic things like use variable expressions side by side, such as $mapType$$mapEnd$ to do a simple replacement. Is there any reason this might be? That is, if I have a single expression, say .*\s*.*abc, and I break it into two variables, .*\s* and .*abc, the expression does not match any text. What could be going 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 of the matching regex causes patterns not to match. What could be going wrong?

I'm trying to do this transformation:

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

Clearly, I need to capture "Array" somehow, as well as only those types which have no arguments.

È stato utile?

Soluzione

SSR matches one or many language constructions per variable, it will NOT capture several variables ($mapType$$mapEnd$) into type reference (or whatever language lexem is). For code like

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

one needs to have search pattern

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

and replace it accordingly. For more complex generic expressions one needs to consider several generic type variables like Map<$Key$, $Value$> One might find this article useful (many concrete SSR example patterns)

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top