Simple structure and replace pattern not recognized

Hi

I'm trying out the structural-search-and-replace functionality in R# and I just cannot get it to work.  I keep on getting "Cannot parse Pattern" when I click the Search now button for the pattern that I created.  I had a look at the sample pattern catalog and for the live of me can't figure out what I am doing wrong.  Can somebody please help?  Here is the export xml snippet of the pattern that I am creating:

  <Pattern Severity="SUGGESTION">
    <Comment>Fetch Child Objects</Comment>
    <ReplaceComment>Temp Test</ReplaceComment>
    <ReplacePattern>$dao$.FetchChildObjects($args$)</ReplacePattern>
    <SearchPattern><![CDATA[return $dao$.FetchChildObjects<$T$>($args$);]]></SearchPattern>
    <Params />
    <Placeholders>
      <TypePlaceholder Name="T" Type="" ExactType="False" />
      <ArgumentPlaceholder Name="args" Minimal="-1" Maximal="-1" />
      <ExpressionPlaceholder Name="dao" ExpressionType="" ExactType="True" />
    </Placeholders>
  </Pattern>



The pattern doesn't really do anything useful yet.  I'm just trying to get it to parse.
3 comments
Comment actions Permalink

OK, I've changed the pattern a bit as below:

  <Pattern Severity="ERROR">
    <Comment>FetchChildObjects without checking UserRights</Comment>
    <ReplaceComment>Replace with FetchChildObjects that checks UserRights</ReplaceComment>
    <ReplacePattern><![CDATA[Collection<$T$> items = $dao$.FetchChildObjects<$T$>($args$);

Notification results = new Notification();
if (!FetchValidator.Execute(items, criteria.ParentId, results))
{
    throw new OnKeyServerException(results.ToString());
}
return items;]]></ReplacePattern>
    <SearchPattern><![CDATA[return $dao$.FetchChildObjects<$T$>($args$);]]></SearchPattern>
    <Params />
    <Placeholders>
      <ArgumentPlaceholder Name="args" Minimal="-1" Maximal="-1" />
      <TypePlaceholder Name="T" Type="" ExactType="True" />
      <IdentifierPlaceholder Name="dao" Type="" ExactType="False" RegEx="" CaseSensitive="True" />
    </Placeholders>
  </Pattern>
</CustomPatterns>



When I initially added the pattern it all worked fine.  When I browse through my code is shows me the errors and the quick fix and that all works fine.  However, if I go Find | Search with Pattern and then select the pattern I created and click the Search Now button, I now suddenly get the cannot parse the pattern error dialog again.  This is seriously frustrating as I now want to find all the places in code where the problem exists and this is prevent me from doing it effectively.X-(  

Also, I have noticed that when I edit a pattern using the R# Search With Pattern dialog, my Visual Studio key mappings go seriously wrong.  I need to restart VS 2010 before everything returns back to normal. Is this also another bug?  Some other detail about my setup:

JetBrains ReSharper 5.1 C# Edition
Build 5.1.1727.12 on 2010-07-07T20:40:20


Please help.
0
Comment actions Permalink

Hello Carel,

Thank you for reporting! I'm afraid I wasn't able to reproduce this behavior.
Could you please attach a screenshot of the error message? Which shortcuts
exactly go wrong after editing a pattern?

Andrey Serebryansky
Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

OK, I've changed the pattern a bit as below:

  <Pattern
> Severity="ERROR">
> <Comment>FetchChildObjects without checking UserRights</Comment>
> <ReplaceComment>Replace with FetchChildObjects that checks
> UserRights</ReplaceComment>
> <ReplacePattern><![CDATA[Collection<$T$> items =
> $dao$.FetchChildObjects<$T$>($args$);
> Notification results = new Notification();
> if (!FetchValidator.Execute(items, criteria.ParentId, results))
> {
> throw new OnKeyServerException(results.ToString());
> }
> return items;]]></ReplacePattern>
> <SearchPattern><![CDATA[return
> $dao$.FetchChildObjects<$T$>($args$);]]></SearchPattern>
> <Params />
> <Placeholders>
> <ArgumentPlaceholder Name="args" Minimal="-1" Maximal="-1" />
> <TypePlaceholder Name="T" Type="" ExactType="True" />
> <IdentifierPlaceholder Name="dao" Type="" ExactType="False"
> RegEx="" CaseSensitive="True" />
> </Placeholders>
> </Pattern>
> </CustomPatterns>

When I initially added the pattern it all worked fine.  When I browse
through my code is shows me the errors and the quick fix and that all
works fine.  However, if I go Find | Search with Pattern and then
select the pattern I created and click the Search Now button, I now
suddenly get the cannot parse the pattern error dialog again.  This is
seriously frustrating as I now want to find all the places in code
where the problem exists and this is prevent me from doing it
effectively.

Also, I have noticed that when I edit a pattern using the R# Search
With Pattern dialog, my Visual Studio key mappings go seriously wrong.
I need to restart VS 2010 before everything returns back to normal. Is
this also another bug?  Some other detail about my setup:

JetBrains ReSharper 5.1 C# Edition
Build 5.1.1727.12 on 2010-07-07T20:40:20
Please help.

---
Original message URL:
http://devnet.jetbrains.net/message/5268705#5268705



0
Comment actions Permalink

Andrey

Find attached a screenshot of the issue.  After the selecting the pattern and then clicking the Search Now button the problem appears.

W.r.t the keyboard mappings going wrong, after I've opened the R# Search and Replace dialog and edited the pattern, my Home key switches between Tabs in VS 2010.  The Up and Down arrows navigates the VS Solution Explorer etc...  Sometimes the ReSharper menu even disappears.    It is only after I restart VS 2010 that everything returns to normal - very frustrating.



Attachment(s):
SearchReplaceError.jpg
0

Please sign in to leave a comment.