I want to create a live template for Timer logger similar to the default live logm template. It uses a Groovy script to collect method parameters and separate them with commas. For instance:
public int func(int a, float b, Object c, String d) { logm }
generate the following code:
public int func(int a, float b, Object c, String d) { Log.d(TAG, "func() called with: a = [" + a + "], b = [" + b + "], c = [" + c + "], d = [" + d + "]"); }
Parameters are collected using the following code:
def params = _2.collect {it + ' = [" + ' + it + ' + "]'}.join(', '); return '"' + _1 + '() called' + (params.empty ? '' : ' with: ' + params) + '"'
The problem is that Timber methods require a type format for parameters, for example:
int a = 5; String s = new String("test"); boolean b = false; Timber.d("%d, %s, %b", a, s, b);
Thus, I need to determine the types of method parameters.