4

How do I auto generate an arbitrary number (Long) for use in a Live Template in IntelliJ?

Example:

public static final long uid = $randomLong$;

where randomLong is replaced with a random long value. I have tried adding the following as an expression for the variable on the live template definition but nothing is generated when the template outputs.

new Random().nextLong()

What I am trying to achieve is very similar to what the IDEA code inspector generates for the Serialization version UID field but with a live template.

travega
  • 8,284
  • 16
  • 63
  • 91

1 Answers1

7

Please try adding groovyScript("new Random().nextLong()") as the variable expression instead.

Peter Gromov
  • 17,615
  • 7
  • 49
  • 35