Search Templates搜索模板
When you construct a template for a structural search you are basically writing a script. 为结构搜索构造模板时,基本上是在编写脚本。To simplify your scripting process, WebStorm offers you a list of predefined search templates that you can use as prototypes for your search template.为了简化脚本编写过程,WebStorm为您提供了预定义“搜索模板”列表,您可以将其用作搜索模板的原型。


On how to access the list of the existing search and replace templates, see the structural search and replace section.有关如何访问现有搜索和替换样板的列表,请参阅结构搜索和替换部分。
A valid search or replacement template represents one of the following supported languages constructs:有效的搜索或替换模板表示以下支持的语言构造之一:
-
Expression, for example表达式,例如"John" + " " + "Doe"
-
Statement, or sequence of statements, for example语句或语句序列,例如document.getElementById("demo").innerHTML = "Hello Dolly.";
-
Class designator, for example类指示符,例如class Engine implements IEngine
-
Line or block comments, for example行注释或块注释,例如/** Created in WebStorm */
In search templates, the following simplifications can be used:在搜索模板中,可以使用以下简化:
-
Method body can be omitted.方法体可以省略。 -
Short class names (instead of fully qualified names) are used in the templates and constraint fields.模板和约束字段中使用短类名(而不是完全限定名)。 -
Using使用class $Class$
as a template results in finding anonymous classes as well.class $Class$
作为模板也可以查找匿名类。 -
Templates for comments and documentation comments should contain variables and constructs with correct comment and JSDoc syntax.注释和文档注释模板应包含具有正确注释和JSDoc语法的变量和结构。
Each search or replace template consists of variables 每个搜索或替换模板由变量$variable_name$
to which you can add a condition (filter) to narrow your search results. $variable_name$
组成,您可以在其中添加条件(筛选器)以缩小搜索结果的范围。Filters depend on a variable in your search template.筛选器取决于搜索模板中的变量。