GoLand 2019.3 Help

Search templates, filters, and script constraints

When you construct a pattern 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 pattern.

Existing search templates for PHP

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.

Count filter

The Count filter specifies a number of occurrences.

For example, in the search pattern, for variable specify min and max numbers in the Count filter field. To set the unlimited maximum count, provide an empty value in the filter field.

GoLand adds [0,∞] to the variable and searches for the specified range of numbers.

Reference filter

The Reference filter lets you reference some other search template in the variable.

The reference will always contain the name of a preconfigured or saved pattern, and you can use auto-completion to fill out this field.

Type filter

The Type filter adds a type of the value or expression that is expected for the specified variable.

Text filter

The Text filter checks the variable against regular expressions or plain text.

Script constraints

The Script filter adds Groovy script constraints to the search pattern. Script constraints are used when you search for certain language constructs.

For example, constructors with the specified number of parameters, or members with the specified visibility modifiers.

All variables used in a pattern 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.

Last modified: 5 December 2019