Intellij Live Template

Can I use the default token value in Intellij Live templates ? For example, I have the following live template that declares a private variable that I would like to create for almost every class:

private static final Logger logger = Logger.getLogger($CLASS$.class)

It seems unnecessary to type $CLASS$ every time this live template is used, because it can be obtained from a class in a scope or file name. I was wondering if the characters indicated by the environment can be used in live templates by default?

+69
java intellij-idea live-templates
May 23 '11 at 13:11
source share
3 answers

Check out some other templates that already use the current class name:

enter image description here

+97
May 23 '11 at 13:24
source share

log4j:

 private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger($CLASS_NAME$.class); 

SLF4J:

 private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger($CLASS_NAME$.class); 

Make sure you set the applicable context in Java and shorten the FQ names and , if defined .

+51
Dec 18 '11 at 15:56
source share

log4j 2:

 private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger($CLASS_NAME$.class); 
+2
Dec 16 '15 at 21:22
source share



All Articles