天天看點

Idea的live template參數中的預定義功能

Item

Description

<code>annotated("annotation qname")</code>

Creates a symbol of type with an annotation that resides at the specified location. For an example, see Live Templates in the iterations group.

<code>arrayVariable()</code>

Suggests all array variables applicable in the current scope. For an example, see Live Templates in the iterations group.

<code>anonymousSuper()</code>

Suggests a supertype for a Kotlin object expression.

<code>сamelCase(String)</code>

Returns the string passed as a parameter, converted to camel case. For example, <code>my-text-file</code>/<code>my text file</code>/<code>my_text_file</code> will be converted to <code>myTextFile</code>.

<code>capitalize(String)</code>

Capitalizes the first letter of the name passed as a parameter.

<code>capitalizeAndUnderscore(sCamelCaseName)</code>

Capitalizes the all letters of a CamelCase name passed as a parameter, and inserts an underscore between the parts. For example, if the string passed as a parameter is<code>FooBar</code>, then the function returns <code>FOO_BAR</code>.

<code>castToLeftSideType()</code>

Casts the right-side expression to the left-side expression type. It is used in the iterationsgroup to have a single template for generating both raw-type and Generics Collections.

<code>className(sClassName)</code>

Returns the name of the current class (the class where the template is expanded).

<code>classNameComplete()</code>

Returns the contents of the system clipboard.

<code>camelCase(String)</code>

Returns CamelCase string out of snake_case string. For example, if the string passed as a parameter is <code>foo_bar</code>, then the function returns <code>fooBar</code>.

<code>complete()</code>

This expression substitutes for the code completion invocation at the variable position.

<code>completeSmart()</code>

This expression substitutes for the smart type completion invocation at the variable position.

<code>componentTypeOf (&lt;array variable or array type&gt;)</code>

<code>currentPackage()</code>

Returns the current package name.

<code>date(sDate)</code>

By default, the current date is returned in the default system format. However, if you specify date format in double quotes, the date will be presented in this format:

<code>decapitalize(sName)</code>

Replaces the first letter of the name passed as a parameter with the corresponding lowercase letter.

<code>descendantClassEnum(&lt;String&gt;)</code>

Shows the children of the class entered as a string parameter.

<code>enum(sCompletionString1,sCompletionString2,...)</code>

List of comma-delimited strings suggested for completion at the template invocation.

Escapes the specified string.

<code>expectedType()</code>

Returns the type which is expected as a result of the whole template. Makes sense if the template is expanded in the right part of an assignment, after return, etc.

<code>fileName(sFileName)</code>

Returns file name with extension.

<code>fileNameWithoutExtension()</code>

Returns file name without extension.

<code>firstWord(sFirstWord)</code>

Returns the first word of the string passed as a parameter.

<code>groovyScript("groovy code")</code>

Returns Groovy script with the specified code.

Also, <code>_editor</code> variable is available inside the script. This variable is bound to the current editor.

<code>guessElementType (&lt;container&gt;)</code>

Makes a guess on the type of elements stored in a <code>java.util.Collection</code>. To make a guess, IntelliJ IDEA tries to find the places where the elements were added to or extracted from the container.

<code>iterableComponentType(&lt;ArrayOrIterable&gt;)</code>

Returns the type of an iterable component, such as an array or a collection.

<code>iterableVariable()</code>

Returns the name of a variable that can be iterated.

<code>lineNumber()</code>

Returns the current line number.

<code>lowercaseAndDash(String)</code>

Returns lower case separated by dashes, of the string passed as a parameter. For example, the string <code>MyExampleName</code> is converted to <code>my-example-name</code>.

<code>methodName()</code>

Returns the name of the embracing method (where the template is expanded).

<code>methodParameters()</code>

Returns the list of parameters of the embracing method (where the template is expanded).

<code>methodReturnType()</code>

Returns the type of the value returned by the current method (the method within which the template is expanded).

<code>qualifiedClassName()</code>

Returns the fully qualified name of the current class (the class where the template is expanded).

Clear the Shorten FQ names check box.

<code>rightSideType()</code>

Declares the left-side variable with a type of the right-side expression. It is used in theiterations group to have a single template for generating both raw-type and Generics Collections.

<code>snakeCase(sCamelCaseText)</code>

Returns snake_case string out of CamelCase string passed as a parameter.

<code>spaceSeparated(String)</code>

Returns string separated with spaces out of CamelCase string passed as a parameter. For example, if the string passed as a parameter is <code>fooBar</code>, then the function returns <code>foo bar</code>.

<code>subtypes(sType)</code>

Returns the subtypes of the type passed as a parameter.

<code>suggestIndexName()</code>

Suggests the name of an index variable. Returns <code>i</code> if there is no such variable in scope, otherwise returns <code>j</code> if there is no such variable in scope, etc.

<code>suggestVariableName()</code>

Suggests the name for a variable based on the variable type and its initializer expression, according to your code style settings that refer to the variable naming rules.

For example, if it is a variable that holds an element within iteration, IntelliJ IDEA makes a guess on the most reasonable names, also taking into account the name of the container being iterated.

<code>suggestFirstVariableName(sFirstVariableName)</code>

Doesn't suggest <code>true, false, this, super</code>.

<code>time(sSystemTime)</code>

Returns the current system time.

<code>typeOfVariable(VAR)</code>

Returns the type of the variable passed as a parameter.

<code>underscoresToCamelCase(sCamelCaseText)</code>

Returns the string passed as a parameter with CamelHump letters substituting for underscores. For example, if the string passed as a parameter is <code>foo_bar</code>, then the function returns <code>fooBar</code>.

<code>underscoresToSpaces(sParameterWithSpaces)</code>

Returns the string passed as a parameter with spaces substituting for underscores.

<code>user()</code>

Returns the name of the current user.

<code>variableOfType(&lt;type&gt;)</code>

Suggests all variables that may be assigned to the type passed as a parameter, for example variableOfType("java.util.Vector"). If you pass an empty string ("") as a parameter, suggests all variables regardless of their types.

<code>JsArrayVariable</code>

Returns JavaScript array name.

<code>jsClassName()</code>

Returns the name of the current JavaScript class.

<code>jsComponentType</code>

Returns the JavaScript component type.

<code>jsMethodName()</code>

Returns the name of the current JavaScript method.

<code>jsQualifiedClassName</code>

Returns the complete name of the current JavaScript class.

<code>jsSuggestIndexName</code>

Returns a suggested name for an index.

<code>jsSuggestVariableName</code>

Returns a suggested name for a variable.

繼續閱讀