Because almost any template file has external references to context variables (and we’ll eventually find their declarations in code rendering that file), we need to introduce declarations for such implicit variables. IntelliJ IDEA helps us to do this in familiar comment-based way: @vtlvariable comment declares name, type and optional scope file for implicit variables; variable type is inferred from method and #foreach usages. Let’s have a look at the latter variant.
Press Alt+Enter on an unresolved collection reference and select a current file declaration:
Appropriate types of Velocity iterables are shown:
It might be undesirable to spread IDE-specific @vtlvariable comments across an entire project, especially in a mixed-IDE team. So, IntelliJ IDEA allows to place all these comments in a single file and use external variable declaration:
An implicitly included file is used for storing the declaration comment and file attribute that determines the scope file for declared variable:
Want IntelliJ IDEA T-Shirt?
Visit our Apparel Store!