2 Replies Last post: Feb 6, 2013 10:04 PM by Daniel Sheiner  
Daniel Sheiner Newbie 2 posts since
Jan 31, 2013
Currently Being Moderated

Jan 31, 2013 8:39 PM

SSR Pattern Question?

Hi,

 

In Resharper 7.1.1000.900 in VS2010, I've created a pattern to search and replace, and it's not finding any instances.  It's intended to take a ternary expression like this:

 

var x = booleanExpression? Foo(a, b, c, 1, d, e, f) : (Foo(a, b, c, 2, d, e, f);

 

and transform it to:

 

var variant = booleanExpression? 1 : 2;

Foo(a, b, c, variant, d, e, f);

 

which is less verbose and easier to read.

 

Here's the search pattern:

 

$id$ = $bool$? $foo$($preArgs$, $variantArg1$, $postArgs$) : $foo$($preArgs$, $variantArg2$, $postArgs$);

 

Here's the replace pattern:

 

var variant = $bool$? $variantArg1$ : $variantArg2$;

$id$ = $foo$($preArgs$, variant, $postArgs$);

 

 

Here are the placeholder definitions:

 

 

NameMeaning
boolexpression which is of type System.Boolean or one of its derived types
foo

identifier

idexpression
postArgsany number of arguments
preArgsany number of arguments
variantArg1exactly one argument
variangArg2exactly one argument

 

 

I've also checked "Match similar constructs", "Format after replace", and "Shorten References".

 

Thanks.

Alex Berezoutsky JetBrains 455 posts since
Feb 18, 2011
Currently Being Moderated
Feb 6, 2013 9:13 PM in response to: Daniel Sheiner
Re: SSR Pattern Question?

Hello Daniel,

 

Thank you for the report. We've checked that out, and it appears to be a bug in R# SSR subsystem. I've logged this issue for further fixing here: http://youtrack.jetbrains.com/issue/RSRP-338199.

 

We apologize for the inconvenience.

Thanks again!

More Like This

  • Retrieving data ...