I'm in Android Studio 3.1.2's File
, Settings...
, Editor
, Live templates
creating a new template named lgg
to aid with debugging my problems with Context
:
Log.w("", "<" + $VAR2$ + "> is value of [$VAR2$]");
Note that $VAR2$
occurs in two places. When I type lgg
and hit tab, the cursor is positioned at the first $VAR2$
spot, like so:
Log.w("", "<" +
[]
+ "> is the value of [
] ")
As I type, for example, mContext, the second $VAR2$
spot echoes what I type, like so:
Log.w("", "<" +
mCo
+ "> is the value of [
mCo
] ")
Great! During execution, stuff like this is output (after I finish typing mContext, and other similar lines):
<com.dslomer64.sqhell.MainActivity@ca3e6b0> is the value of [mContext]
<android.view.ContextThemeWrapper@e330929> is the value of [builder.getContext()]
<android.app.AlertDialog$Builder@73b94ae> is value of [builder]
<android.widget.TextView{7c6ce5b V.ED..... ......ID 0,0-0,0}> is the value of [message]
I'd rather have the name of the object precede the value instead of value preceding object name. I'd rather have this as debugging output...
The value of [mContext] is <com.dslomer64.sqhell.MainActivity@ca3e6b0>
But in order to get the object name displayed first, it has to be inside double quotes. That is, the template would have to be ...
Log.w("", "The value of [$VAR2$] is [" + $VAR2$ + "]")
... in order to translate into ...
Log.w("", "The value of [mContext] is <" + mContext +">");
... to make the output become ...
The value of [mContext] is <com.whoever.whatever.MainActivity@ca3e6b0>
But then autocomplete is impossible.
So.
What would that template have to look like in order for the cursor to be placed here at the second $VAR2$
...
Log.w("", "<" +
+ "> is the value of [
[]
] ")
... with the echoing of typing occurring in the first $VAR2$
?