Postfix Completion
The Postfix Completion functionality allows developers to wrap a code fragment with a predefined template by typing a template abbreviation just after an expression meant to be wrapped, expanded, or modified. It relieves developers from typing repetitive or non-trivial code or helps to create the code faster, e.g., often it is convenient to write a code part and surround it with the required block without navigating the caret backward.
Consider a situation where a developer is not very familiar with a current Java project API and doesn't know how to name a variable that will be a result of an expression they want to type. The postfix completion makes it possible to write an expression at first and create a variable assignment with suggested names by adding a postfix template abbreviation at the end of the expression.
Assume that a user typed the following Java code:
To avoid moving the caret to the beginning of the line, the user can quickly create a variable assignment by adding the .var
postfix abbreviation and expanding the template:
When the template is applied, the above code is expanded to:
In addition, the user can choose the best matching variable name from the name suggestions popup.
These sections describe how to implement Postfix Templates, and their associated building blocks, to plugins: