Search Templates
Last modified: 21 July 2022When you construct a template for a structural search you are basically writing a script. To simplify your scripting process, GoLand offers you a list of predefined search templates that you can use as prototypes for your search template.

On how to access the list of the existing search and replace templates, see the structural search and replace section.
Each search or replace template consists of variables $variable_name$
to which you can add a condition (filter) to narrow your search results. Filters depend on a variable in your search template.
The Count filter specifies a number of occurrences.
If you do not set the Count filter explicitly, the IDE looks for only one template match. In other words, when the Count filter is not applied, the default values for the filter are min = 1
and max = 1
.
GoLand adds [0,∞]
to the variable and searches for the specified range of numbers.
The Script filter adds Groovy script constraints to the search template. Script constraints are used when you search for certain language constructs.
All variables used in a template can be accessed from script constraints. When you add a script constraint to your variable, GoLand matches it against the PSI tree, this variable is in fact a node in the PSI tree.

note
__context__ corresponds to the Complete match variable.
Thanks for your feedback!