Structure Replace How To question:

Hi all,

I need to change loads of

assertEquals ("aaaaaaaa" , foo (p );
assertEquals ("bbbbbbbb" , foo (p) );

into
assertEquals ("prefix 1 - aaaaaaaa" , bar (p) );
assertEquals ("prefix 1 - bbbbbbbb" , bar (p) );


Any idea?

14 comments

Hi,

Is the following not working?:

assertEquals ("$a$" , foo (p) ); by
assertEquals ("prefix 1 - $a$" , bar (p) );

Alain Ravet wrote:

Hi all,

I need to change loads of

assertEquals ("aaaaaaaa" , foo (p );
assertEquals ("bbbbbbbb" , foo (p) );

into
assertEquals ("prefix 1 - aaaaaaaa" , bar (p) );
assertEquals ("prefix 1 - bbbbbbbb" , bar (p) );


Any idea?



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

Maxim,

1/
I'm clueless: the same pattern
assertEquals ("$a$" , logOfGameAndTotal (__topUI) );
returns dozens of matches, in Structural Search, but none in Replace
Structural.


2/
Additionaly, working with RS is a pain, because you have to be right the
first time: make a typo, and it closes silently, returning nothing, and
you have to start again. It's a shame, because SS and RS are really
powerful tools, but I can't make them work for me.

It should be easier, a lot easier to work with. That's the motivation
behind :

"Structural Search : add /don't close query/ and /auto-run in
background/ checkboxes. "
http://intellij.net/tracker/idea/viewSCR?publicId=38333

Alain

0

Hi,
you can 'Edit Query' from search results, last query is also opened when
you open the dialog,
'Run in the background' option with closing the dialog seems fine for me.

Alain Ravet wrote:

Maxim,

1/
I'm clueless: the same pattern
assertEquals ("$a$" , logOfGameAndTotal (__topUI) );
returns dozens of matches, in Structural Search, but none in Replace
Structural.


2/
Additionaly, working with RS is a pain, because you have to be right the
first time: make a typo, and it closes silently, returning nothing, and
you have to start again. It's a shame, because SS and RS are really
powerful tools, but I can't make them work for me.

It should be easier, a lot easier to work with. That's the motivation
behind :

"Structural Search : add /don't close query/ and /auto-run in
background/ checkboxes. "
http://intellij.net/tracker/idea/viewSCR?publicId=38333

Alain



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

Maxim

Hi,
you can 'Edit Query' from search results, last query is also opened
when you open the dialog,



No, I can't, not when /Replace Structural/ found no match - *1 - for a
pattern that would find dozens of match when run in /Structural Search/

*1: no match in RS =>
- dialog closes silently, and
- there is no panel where to find an 'Edit Query' button


Alain

0

Hi,

This behavior (silet close) may be due to an exception, please, check
out idea logs.
Aside this you can press the 'Background' button and empty Find tool
window should appear ('Edit Query' is available in this toolwindow).

Alain Ravet wrote:

Maxim

>> Hi,
>> you can 'Edit Query' from search results, last query is also opened
>> when you open the dialog,



No, I can't, not when /Replace Structural/ found no match - *1 - for a
pattern that would find dozens of match when run in /Structural Search/

*1: no match in RS =>
- dialog closes silently, and
- there is no panel where to find an 'Edit Query' button


Alain



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

Alain Ravet wrote:

2/
Additionaly, working with RS is a pain, because you have to be right the
first time: make a typo, and it closes silently, returning nothing, and
you have to start again. It's a shame, because SS and RS are really
powerful tools, but I can't make them work for me.


Yep. I was about to submit a request to add an "Edit query" button to the
dialog that says "No occurrences found in ". However your suggestion
to keep the query window open while it is running in the background sounds
even better.

I quickly learned the keyboard shortcut for SS though :/

Sascha

0

Maxim,

I've just found why RS wouldn't find matches: there was an extra space
at the end of the pattern.
SS would ignore it, but not RS.
This is a bug, don't you think?

This behavior (silet close) may be due to an exception, please, check
out idea logs.


I checked idea.log : nothing special.

Aside this you can press the 'Background' button and empty Find tool
window should appear ('Edit Query' is available in this toolwindow).



What is the 'Background' button?


Alain

0

Hi,

Please, exactly quote the queries used.
Background button appears on Progress dialog along with 'Cancel' button,
maybe your scope is small and find works just too fast :).

Alain Ravet wrote:

Maxim,

I've just found why RS wouldn't find matches: there was an extra space
at the end of the pattern.
SS would ignore it, but not RS.
This is a bug, don't you think?

>> This behavior (silet close) may be due to an exception, please, check
>> out idea logs.


I checked idea.log : nothing special.

>> Aside this you can press the 'Background' button and empty Find tool
>> window should appear ('Edit Query' is available in this toolwindow).



What is the 'Background' button?


Alain



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

Maxim,

Please, exactly quote the queries used.



It's the one I mentioned above:
assertEquals ("$a$" , logOfGameAndTotal (__topUI) ); <-ends
here: note the space, after the ';'

Background button appears on Progress dialog along with 'Cancel'
button, maybe your scope is small and find works just too fast :).

>

That must be it.

Alain

0

Maxim,

It's broken again. Here is some more details, and screen copy.


Step1 : I use the pattern with S.S
=> finds 9 matches

Structural Search



Step2: I copy and paste the pattern from S.S to R.S
=> no matches, and no result panel shows.
Structural Replace




For completeness, here is idea.log contents, after I ran the RS:

2004-10-28 16:04:11,559 INFO -
plication.impl.LaterInvocatorEx -
enterModal:com.intellij.openapi.i.a.a$d_[dialog25,47,22,0x0,invalid,hidden,layout=java.awt.BorderLayout,modal,title=Structural
Search - user
defined,defaultCloseOperation=DO_NOTHING_ON_CLOSE,rootPane=com.intellij.openapi.i.a.a$4[,0,0,0x0,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=null,alignmentY=null,border=,flags=449,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]

2004-10-28 16:05:24,747 INFO -
lication.impl.LaterInvocatorEx -
leaveModal:com.intellij.openapi.i.a.a$d_[dialog25,558,143,579x361,invalid,hidden,layout=java.awt.BorderLayout,modal,title=Structural
Search - user
defined,defaultCloseOperation=DO_NOTHING_ON_CLOSE,rootPane=com.intellij.openapi.i.a.a$4[,0,22,579x339,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=null,alignmentY=null,border=,flags=449,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]

2004-10-28 16:05:24,783 INFO -
fs.impl.VirtualFileManagerImpl - afterRefreshFinish()
2004-10-28 16:05:28,082 INFO -
lication.impl.LaterInvocatorEx -
enterModal:com.intellij.openapi.i.a.a$d_[dialog26,47,22,0x0,invalid,hidden,layout=java.awt.BorderLayout,modal,title=Replace
in
Project,defaultCloseOperation=DO_NOTHING_ON_CLOSE,rootPane=com.intellij.openapi.i.a.a$4[,0,0,0x0,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=null,alignmentY=null,border=,flags=449,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]

2004-10-28 16:06:24,673 INFO -
lication.impl.LaterInvocatorEx -
leaveModal:com.intellij.openapi.i.a.a$d_[dialog26,500,386,675x411,invalid,hidden,layout=java.awt.BorderLayout,modal,title=Replace
in
Project,defaultCloseOperation=DO_NOTHING_ON_CLOSE,rootPane=com.intellij.openapi.i.a.a$4[,0,22,675x389,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=null,alignmentY=null,border=,flags=449,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]

2004-10-28 16:06:24,848 INFO -
ageView.impl.UsagesNodeManager - com.intellij.usageView.a.d@b84276 release
2004-10-28 16:06:34,955 INFO -
ject.impl.BaseFileConfigurable - Time to save
/Users/aravet/IdeaProjects/BownlingRoutine1/modules/Main/Main.iml: 1
2004-10-28 16:06:35,028 INFO -
ject.impl.BaseFileConfigurable - Time to save
/Users/aravet/IdeaProjects/BownlingRoutine1/BownlingRoutine1.ipr: 6
2004-10-28 16:06:35,222 INFO -
ject.impl.BaseFileConfigurable - Time to save
/Users/aravet/IdeaProjects/BownlingRoutine1/BownlingRoutine1.iws: 13
2004-10-28 16:06:35,223 INFO -
lij.localVcs.impl.LocalVcsImpl - enter: save(repositorySize=12070)
2004-10-28 16:06:35,343 INFO -
lij.localVcs.impl.LocalVcsImpl - purged 11 items
2004-10-28 16:06:35,358 INFO -
lij.localVcs.impl.LocalVcsImpl - repositorySizeAfterPurging=12059; Time
to purge: 135
2004-10-28 16:06:35,739 INFO -
lij.localVcs.impl.LocalVcsImpl - exit: save(repositorySize=12059)



Attachment(s):
pic StructuralSearch.pdf
pic StructuralReplace.pdf
0

Hi,

Argh, nice idea to attach the images.

You have used Replace in Path, but not the Structural Replace

Alain Ravet wrote:

Maxim,

It's broken again. Here is some more details, and screen copy.


Step1 : I use the pattern with S.S
=> finds 9 matches

Structural Search



Step2: I copy and paste the pattern from S.S to R.S
=> no matches, and no result panel shows.
Structural Replace




For completeness, here is idea.log contents, after I ran the RS:

2004-10-28 16:04:11,559 INFO -
plication.impl.LaterInvocatorEx -
enterModal:com.intellij.openapi.i.a.a$d_[dialog25,47,22,0x0,invalid,hidden,layout=java.awt.BorderLayout,modal,title=Structural
Search - user
defined,defaultCloseOperation=DO_NOTHING_ON_CLOSE,rootPane=com.intellij.openapi.i.a.a$4[,0,0,0x0,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=null,alignmentY=null,border=,flags=449,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]

2004-10-28 16:05:24,747 INFO -
lication.impl.LaterInvocatorEx -
leaveModal:com.intellij.openapi.i.a.a$d_[dialog25,558,143,579x361,invalid,hidden,layout=java.awt.BorderLayout,modal,title=Structural
Search - user
defined,defaultCloseOperation=DO_NOTHING_ON_CLOSE,rootPane=com.intellij.openapi.i.a.a$4[,0,22,579x339,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=null,alignmentY=null,border=,flags=449,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]

2004-10-28 16:05:24,783 INFO -
fs.impl.VirtualFileManagerImpl - afterRefreshFinish()
2004-10-28 16:05:28,082 INFO -
lication.impl.LaterInvocatorEx -
enterModal:com.intellij.openapi.i.a.a$d_[dialog26,47,22,0x0,invalid,hidden,layout=java.awt.BorderLayout,modal,title=Replace
in
Project,defaultCloseOperation=DO_NOTHING_ON_CLOSE,rootPane=com.intellij.openapi.i.a.a$4[,0,0,0x0,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=null,alignmentY=null,border=,flags=449,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]

2004-10-28 16:06:24,673 INFO -
lication.impl.LaterInvocatorEx -
leaveModal:com.intellij.openapi.i.a.a$d_[dialog26,500,386,675x411,invalid,hidden,layout=java.awt.BorderLayout,modal,title=Replace
in
Project,defaultCloseOperation=DO_NOTHING_ON_CLOSE,rootPane=com.intellij.openapi.i.a.a$4[,0,22,675x389,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=null,alignmentY=null,border=,flags=449,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]

2004-10-28 16:06:24,848 INFO -
ageView.impl.UsagesNodeManager - com.intellij.usageView.a.d@b84276 release
2004-10-28 16:06:34,955 INFO -
ject.impl.BaseFileConfigurable - Time to save
/Users/aravet/IdeaProjects/BownlingRoutine1/modules/Main/Main.iml: 1
2004-10-28 16:06:35,028 INFO -
ject.impl.BaseFileConfigurable - Time to save
/Users/aravet/IdeaProjects/BownlingRoutine1/BownlingRoutine1.ipr: 6
2004-10-28 16:06:35,222 INFO -
ject.impl.BaseFileConfigurable - Time to save
/Users/aravet/IdeaProjects/BownlingRoutine1/BownlingRoutine1.iws: 13
2004-10-28 16:06:35,223 INFO -
lij.localVcs.impl.LocalVcsImpl - enter: save(repositorySize=12070)
2004-10-28 16:06:35,343 INFO -
lij.localVcs.impl.LocalVcsImpl - purged 11 items
2004-10-28 16:06:35,358 INFO -
lij.localVcs.impl.LocalVcsImpl - repositorySizeAfterPurging=12059; Time
to purge: 135
2004-10-28 16:06:35,739 INFO -
lij.localVcs.impl.LocalVcsImpl - exit: save(repositorySize=12059)



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

Maxim Mossienko wrote:

>

Argh, nice idea to attach the images.
You have used Replace in Path, but not the Structural Replace



Duh. Thanks.

I was misled by the shortcuts:

Search Structure == command shift S
Replace Structure == command shift M

I was using
command shift *R,
*that's mapped
to Replace in Path

Alain

0

It should be easier, a lot easier to work with. That's the motivation
behind :


Completely agree. This tool has such a steep learning curve that I'm
sure it's the most under utilized tool, yet probably one of the most
powerful.

Vince.


1

It would be nice if ANY of this was in the documentation on Structure search but it is not.  Seriously guys, this is worse than Apple's documentation.  If you hate graphics or images or examples or any useful information refer to this page: https://www.jetbrains.com/help/idea/2016.2/structural-search-and-replace.html

0

Please sign in to leave a comment.