ssh ssh - 6 months ago 38
Android Question

Auto-generate Android Log TAG in Android Studio/Intellij idea

In Intellij Idea when i typing

psfs
and then press Ctrl+J IDE was getting me a dialog :

enter image description here

And when i press Enter i get an

enter image description here

I know where i can customize my own output

enter image description here

But i can't any doc's how i can write my own live template.

In the end i want to get next result :

Typing :
psfst
-> press Ctrl+J -> press Enter



Result :



public static final String TAG = <currentClassName>.class.getSimpleName();


It will be so helpfull, because i have a habit to log my classes.

ssh ssh
Answer

I find a solution

1) Create a new live template in plain group
2) In template text :

private static final String TAG = $CLASS_NAME$.class.getSimpleName();

3) Define a usage scope :

enter image description here

4) Choose a shortcut :

enter image description here

finally click on Edit variables and change expression value to className()

enter image description here

Click Ok , Apply, Ok and use.