0

I'm looking for a solution to:

  1. store favorite "Find Occurrences of ..." and
  2. execute them without any more questions by the UI in one stroke

I know the option ALT + 3 -> STRG + E to open the last Find Usages, but that are only "Find" and not "Replace in Path" actions

Maybe I need to develop a plugin - that could look like this:

DO REPLACEMENTS:
----------------------------------
[X] foo -> bar
[ ] bar -> foo
[X] ): boolean -> ): bool
----------------------------------
[add] [execute] [execute & review]
----------------------------------

but any other ideas are welcome!

Important is to use PhpStorm`s file scopes! Because I would like to use my own custom scope.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
timo kranz
  • 153
  • 1
  • 2
  • 13
  • There are no such functionality. You can try recording a macro though... (but it's unlikely to do what you want -- you cannot check what steps to run and when to stop). Otherwise -- code your own plugin -- the best and most flexible way from any POV. – LazyOne Sep 23 '17 at 17:04
  • Macros dont work (macros *never* works! if i try something with macros :-) ) – timo kranz Sep 23 '17 at 17:59

1 Answers1

2

You can use "Structural Search Inspection". It's base on the "Structural Search and Replace" engine which is pretty powerful. Once configured you can run the inspection using the "Run Inspection by Name..." action with a custom scope. It has a quick fix which can be used to replace occurrences.

artspb
  • 1,127
  • 1
  • 10
  • 19
  • That seems to be the Answer, but i dont get it work with what ive tried: class $class$ { public function $method$(): $returnType$ { } – timo kranz Sep 29 '17 at 18:20
  • ...and can i get quick access to my saved searches by a toolwindow or keyboard shortcut or macro? – timo kranz Sep 29 '17 at 18:25
  • You can assign a shortcut on the "Search Structurally..." action, it doesn't have it by default. But I'd still recommend configuring "Structural Search Inspection" which runs a search automatically. Back to a search query you've mentioned. What are you trying to achieve? What would you like to find? – artspb Sep 30 '17 at 15:15
  • my goal is to define some preferences of search/replacement code templates to fix all my code style problems before the code sniffer tells me these errors ;-) ... as simple as possible. with a short-cut ..... I don't know how suitable code-templates are for this idea. – timo kranz Sep 30 '17 at 17:07
  • Nice Tip with "Structural Search Inspection" - Thanks - but i have trouble to learn how to use these templates... – timo kranz Sep 30 '17 at 17:48
  • See: https://stackoverflow.com/questions/46506157/intellij-structural-search-in-php-to-find-specific-return-types – timo kranz Sep 30 '17 at 19:10