想法实时模板记录方法Args [英] Idea Live Template to Log Method Args

查看:104
本文介绍了想法实时模板记录方法Args的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在Jetbrain的Idea中创建一个能够记录方法参数的实时模板。我们称之为大。它的工作方式如下:

I would like to be able to create a live template in Jetbrain's Idea that will log the method's arguments. Let's call it "larg". It would work like:

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

创建

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

我很好地获取方法名称,但还没弄明白如何引入方法参数。有什么想法吗?

I'm fine with getting the method name in, but have not figured out how to pull in the method arguments. Any ideas?

推荐答案

我已经晚了4年,但预定义的模板soutp几乎使用groovyscript变量。

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

这是一个groovy脚本,它可以满足您的需求

Here's the groovy script that does what you're looking for

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

这篇关于想法实时模板记录方法Args的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆