PyCharm 2017.2 Help

Structural Search and Replace. Edit Variable Dialog

Edit | Find | Search Structurally | Edit variables


Use this dialog to define constraints for the variables of a search template.

ItemDescription
Variables This area shows a list of variables used in the current search template.
Text constraints In this area define the following constraints of the selected variable regarding text:
  • Text/regular expression - in this text box, type a perl-like expression or a class name to be used as a variable constraint. Basic code completion is available for class names.
  • Invert condition - select this check box to have the text pattern inverted.
  • Apply constraint within type hierarchy - select this check box to have the search according to the pattern performed both in type names and in parents (within the hierarchy).
  • Whole words only - when this check box is selected, only whole words within text are matched. This option recognizes string literals and comments.
Occurrences count In this area, define how pattern hits will be counted.
  • Minimum count - in this text box, type the minimum number of elements in the list.
  • Maximum count - in this text box, type the maximum number of elements in the list.
  • Unlimited - select this check box to allow unlimited number of elements in the list.
Expression constraints In this area, define how expressions should be processed.
  • Value is read - if this check box is selected, the matching variable is to be read.
  • Value is written - if this check box is selected, the matching variable is to be written.
  • Expression type (regexp) - if the calculated variable is an expression, this constraint checks its type. For instance, for the foo($a$) expression the type of the method parameter would be checked.
  • Expected type of expression (regexp) - if the calculated variable is matched to any expected type of an expression, this constraint checks the expression type anywhere the expression was used. For instance, correspondence between the method parameter type (e.g. $a$) in method calls will be checked for methods like foo($a$).
  • Apply constraint within type hierarchy - select this check box to have the search according to the pattern performed both in type names and in parents (within the hierarchy).
  • Invert condition - select this check box to have the value of the corresponding check box changed to the opposite one.
Script constraints In this area, define a variable constraint via a script. Specify the script in the text box or click the /help/img/idea/2017.2/browseButton.png button to open the Edit Groovy Script Constraint dialog box. The constraint is applied after the initial matching process is finished.
This variable is target of the search If this check box is selected, the search results will show not the entire expression but the selected variable(s) only.
Last modified: 26 October 2017

See Also