Idea Live Template to Log Method Args

I would like to be able to create a live template in the Jetbrain Idea that will record the arguments of the method. Let me call it "big." It will work as follows:

public void get(String one, String two) { larg<tab> 

create

 public void get(String one, String two) { log.info("get: one = " + one + " two = " + two); 

I am fine with the method name, but did not understand how to use the method arguments. Any ideas?

+6
java intellij-idea ide
source share
3 answers

I'm 4 years late, but the predefined soutp pattern pretty much does this using the groovyscript variable.

Here the groovy script does what you are looking for

 groovyScript("'\"' + _1.collect { it + ' = [\" + ' + it + ' + \"]'}.join(', ') + '\"'", methodParameters()) 
+11
source share

It's already 6 years, but I found a well-described solution. (I don't have soutp templates in my templates) http://artfulonline.blogspot.com.au/2014/03/quick-logging-with-intellij-live.html

+3
source share

It seems currently impossible to create a live template.

From the Jetbrain forum :

 There is no predefined live template function to do this for you automatically. You can write a plugin that would provide such a function. 
0
source share

All Articles