Live Template that can inferr variable type

6 views
Skip to first unread message

Wim Velzeboer

unread,
Jan 16, 2026, 11:52:39 AMJan 16
to Illuminated Cloud Q&A
Hi

I am struggling with setting up a live template that has two variables.
One accepting a variable name and the other that should preferably automatically infer the type of the variable entered in the first live template variable.

Something like:

(($INTERFACE$) mock.verify($INSTANCE$)).$METHOD$($PARAMS$);
$END$

INSTANCE => apexVariable([type])
INTERFACE => typeOfVariable(INSTANCE)

If think the documentation says that the `typeOfVariable` should be used, but is only available for JAVA. Is there an alternative for doing this in Apex?

Is there also somewhere documentation of the available live-template variable functions in Illuminated cloud?

Thanks for the help!

Wim
Screenshot from 2026-01-16 09-56-37.png

Scott

unread,
Jan 16, 2026, 11:54:17 AMJan 16
to Illuminated Cloud Q&A, wimvel...@gmail.com
Hi. All of the Apex-specific macros start with "apex", so you can use "apexTypeOfVariable(variable)" to get the inferred type. Take a look at the bundled Apex "lazy" macro which also uses it.

Regards,
Scott Wells

Wim Velzeboer

unread,
Jan 16, 2026, 12:17:05 PMJan 16
to Illuminated Cloud Q&A, Scott, Wim Velzeboer
Yes, that seems to work perfectly!

INTERFACE => apexTypeOfVariable(INSTANCE)

Is there anywhere some documentation for all these apex* methods that I can use? Maybe I can simplify some of my other templates :-)

Thanks!

Scott

unread,
Jan 16, 2026, 12:28:42 PMJan 16
to Illuminated Cloud Q&A, wimvel...@gmail.com, Scott
This isn't perfect, but in the live template variables editor, you can see them listed in the Expression field:

Apex_Live_Template_Macros.png

The ones that start with "apex" are the ones specifically for that context. Most of them were modeled directly after the Java analogs.

If you're not sure what one is intended to do, or if you aren't able to find one you need (which may well mean that I didn't need it either), let me know and I'll help.

Regards,
Scott Wells
Reply all
Reply to author
Forward
0 new messages