IntelliJ IDEA live Templates

My Log


<templateSet group="MyLog">
    <template name="psl"
              value="private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger($CLASS_NAME$.class);"
              shortcut="ENTER" description="logback日志对象" toReformat="false" toShortenFQNames="true"
              useStaticImport="true">
        <variable name="CLASS_NAME" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_DECLARATION" value="true"/>
            <option name="JAVA_EXPRESSION" value="true"/>
            <option name="JAVA_STATEMENT" value="true"/>
        context>
    template>
    <template name="logp" value="log.$VAR$("【$METHOD_NAME$】::$PLACE_HOLDERS$",$ARGUMENTS$);" shortcut="ENTER"
              description="log输出带参日志" toReformat="true" toShortenFQNames="true" useStaticImport="true">
        <variable name="VAR" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="PLACE_HOLDERS"
                  expression="groovyScript("_1.collect { it + ' = [{}]'}.join(', ') ", methodParameters())"
                  defaultValue="" alwaysStopAt="false"/>
        <variable name="METHOD_NAME" expression="methodName()" defaultValue="" alwaysStopAt="false"/>
        <variable name="ARGUMENTS"
                  expression="groovyScript("_1.collect { it }.join(', ') ", methodParameters())"
                  defaultValue="" alwaysStopAt="false"/>
        <context>
            <option name="JAVA_STATEMENT" value="true"/>
        context>
    template>
    <template name="pll"
              value="private static org.apache.logging.log4j.Logger LOG = LogManager.getLogger($CLASS_NAME$.class);"
              shortcut="ENTER" description="log4j日志对象" toReformat="true" toShortenFQNames="true">
        <variable name="CLASS_NAME" expression="className()" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_DECLARATION" value="true"/>
            <option name="JAVA_EXPRESSION" value="true"/>
            <option name="JAVA_STATEMENT" value="true"/>
        context>
    template>
    <template name="logs" value="log.$VAR$("$EXPR_COPY$ ==> 【{}】",$EXPR$);" shortcut="ENTER"
              description="log输出日志" toReformat="true" toShortenFQNames="true">
        <variable name="VAR" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="EXPR" expression="variableOfType("")" defaultValue=""expr""
                  alwaysStopAt="true"/>
        <variable name="EXPR_COPY" expression="escapeString(EXPR)" defaultValue="" alwaysStopAt="false"/>
        <context>
            <option name="JAVA_STATEMENT" value="true"/>
        context>
    template>
    <template name="logm" value="log.$VAR$("【$METHOD_NAME$】::$EXPR_COPY$ ==> 【{}】",$EXPR$);"
              shortcut="ENTER" description="log输出方法名日志" toReformat="true" toShortenFQNames="true">
        <variable name="VAR" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="METHOD_NAME" expression="methodName()" defaultValue="" alwaysStopAt="false"/>
        <variable name="EXPR" expression="variableOfType("")" defaultValue=""expr""
                  alwaysStopAt="true"/>
        <variable name="EXPR_COPY" expression="escapeString(EXPR)" defaultValue="" alwaysStopAt="false"/>
        <context>
            <option name="JAVA_STATEMENT" value="true"/>
        context>
    template>
templateSet>

MybatisCodeHelperPro.xml


<templateSet group="MybatisCodeHelperPro">
    <template name="cw"
              value="		<choose>
                <when test="$var1$">
                    $var2$
                </when>
                <otherwise>
                    $var3$
                </otherwise>
            </choose>"
              shortcut="ENTER" description="choose when otherwise" toReformat="true" toShortenFQNames="false">
        <variable name="var1" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="var2" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="var3" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="MybatisSql" value="true"/>
        context>
    template>
    <template name="wa"
              value="<where>
            <if test="$var1$">
                $var2$
            </if>
            <if test="$var3$">
                and  $var4$
            </if>
        </where>"
              shortcut="ENTER" description="where and" toReformat="true" toShortenFQNames="false">
        <variable name="var1" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="var2" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="var3" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="var4" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="MybatisSql" value="true"/>
        context>
    template>
    <template name="table" value="<!--@Table $var1$-->$END$" shortcut="ENTER"
              description="set table name for current xml" toReformat="true" toShortenFQNames="false">
        <variable name="var1" expression="tableName" defaultValue="" alwaysStopAt="true"/>
        <context/>
    template>
    <template name="sup" value=" <!--suppress SqlResolve -->" shortcut="ENTER" description="Ignore sql errors"
              toReformat="true" toShortenFQNames="false">
        <context>
            <option name="XML_TEXT" value="true"/>
        context>
    template>
templateSet>

MyGroup.xml


<templateSet group="MyGroup">
    <template name="*"
              value="** 
 * $methodName$
        * 
 * @author $author$
        * @date $date$ $time$
        $param$
* @return $return$
        */"
              shortcut="TAB" description="方法注释" toReformat="true" toShortenFQNames="true">
        <variable name="methodName" expression="methodName()" defaultValue="" alwaysStopAt="true"/>
        <variable name="author" expression="user()" defaultValue="" alwaysStopAt="true"/>
        <variable name="time" expression="time()" defaultValue="" alwaysStopAt="true"/>
        <variable name="date" expression="date()" defaultValue="" alwaysStopAt="true"/>
        <variable name="param"
                  expression="groovyScript("def result=''; def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList(); for(i = 0; i < params.size(); i++) {result+=' * @param ' + params[i] + ' '+params[i]  + ((i < params.size() - 1) ? '\\n' : '')}; return result", methodParameters()) "
                  defaultValue="" alwaysStopAt="true"/>
        <variable name="return" expression="methodReturnType()" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="td" value="// TODO   $date$   $user$   $end$" shortcut="ENTER" description="TODO  Area"
              toReformat="true" toShortenFQNames="true">
        <variable name="date" expression="date()" defaultValue="" alwaysStopAt="true"/>
        <variable name="user" expression="user()" defaultValue="" alwaysStopAt="true"/>
        <variable name="end" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="fix" value="// FIXME  $date$   $user$   $end$" shortcut="ENTER" description="FIXME  area"
              toReformat="true" toShortenFQNames="true">
        <variable name="date" expression="date()" defaultValue="" alwaysStopAt="true"/>
        <variable name="user" expression="user()" defaultValue="" alwaysStopAt="true"/>
        <variable name="end" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="pll"
              value="private static org.apache.logging.log4j.Logger LOG = LogManager.getLogger($CLASS_NAME$.class);"
              shortcut="ENTER" description="log4j日志对象" toReformat="true" toShortenFQNames="true">
        <variable name="CLASS_NAME" expression="className()" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="/*" value="/**
 * $END$
 */" shortcut="ENTER" description="javadoc注释" toReformat="true"
              toShortenFQNames="true">
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="pres"
              value="public RestResponse<Map<String, Object>> $VAR1$(){
    Map<String, Object> map = new HashMap<>(4);
    map.put("code", 200);
    map.put("msg", "success");
    $END$
    return RestResponse.ok(map);
}
 "
              shortcut="ENTER" description="public RespMsg方法" toReformat="true" toShortenFQNames="true">
        <variable name="VAR1" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="aw" value="@Autowired
private $VAR1$ $VAR2$;
$END$" shortcut="ENTER"
              description="新建Autowired" toReformat="true" toShortenFQNames="true">
        <variable name="VAR1" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="VAR2" expression="decapitalize(VAR1)" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="rs" value="@Resource
private $VAR1$ $VAR2$;
$END$" shortcut="ENTER" description="新建Resource"
              toReformat="true" toShortenFQNames="true">
        <variable name="VAR1" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="VAR2" expression="decapitalize(VAR1)" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="ppm"
              value="@PostMapping("$VAR1$")
public $VAR$ $VAR1$(){
    $END$
    return null;
}"
              shortcut="ENTER" description="post方法" toReformat="true" toShortenFQNames="true">
        <variable name="VAR1" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="VAR" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="pm" value="public $VAR$ $VAR1$(){
    $END$
}
" shortcut="ENTER"
              description="public  非静态方法" toReformat="true" toShortenFQNames="true">
        <variable name="VAR1" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="VAR" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="gpm"
              value="@GetMapping("$VAR1$")
public $VAR$ $VAR1$(){
    $END$
    return null;
}"
              shortcut="ENTER" description="get方法" toReformat="true" toShortenFQNames="true">
        <variable name="VAR1" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="VAR" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="prm" value="private $VAR$ $VAR1$(){
    $END$

}" shortcut="ENTER"
              description="private 非静态方法" toReformat="true" toShortenFQNames="true">
        <variable name="VAR1" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="VAR" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="psm" value="public static $VAR$ $VAR1$(){
    $END$

}
" shortcut="ENTER"
              description="public  static 方法" toReformat="true" toShortenFQNames="true">
        <variable name="VAR1" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="VAR" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="tpvm" value="@Test
public void $VAR1$(){
    $END$
}" shortcut="ENTER"
              description="Junit test方法" toReformat="true" toShortenFQNames="true">
        <variable name="VAR1" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="fixm" value="/**
 * FIXME  $date$  $user$  $end$
 */" shortcut="ENTER"
              description="FIXME method  area" toReformat="true" toShortenFQNames="true">
        <variable name="date" expression="date()" defaultValue="" alwaysStopAt="true"/>
        <variable name="user" expression="user()" defaultValue="" alwaysStopAt="true"/>
        <variable name="end" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
templateSet>

MyGroup2.xml


<templateSet group="MyGroup2">
    <template name="tolist" value="List<$TYPE$> $VAR$ = new ArrayList<>($ITERABLE_TYPE$);
$END$"
              shortcut="ENTER" description="转list" toReformat="true" toShortenFQNames="true">
        <variable name="TYPE" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="VAR" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="ITERABLE_TYPE" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="map.iter"
              value="for (Map.Entry<$ITERABLE_TYPE$> entry : map.entrySet()) {
    System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
    $END$
}
"
              shortcut="ENTER" description="遍历map" toReformat="true" toShortenFQNames="true">
        <variable name="ITERABLE_TYPE" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="toSet" value="Set<$TYPE$> $VAR$ = new HashSet<>($ITERABLE_TYPE$);
 $END$"
              shortcut="ENTER" description="list转set" toReformat="true" toShortenFQNames="true">
        <variable name="TYPE" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="VAR" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="ITERABLE_TYPE" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="nc" value="$Clazz$ $obj$ = new $Clazz$();
$END$" shortcut="ENTER" description="新建对象"
              toReformat="true" toShortenFQNames="true">
        <variable name="Clazz" expression="classNameComplete()" defaultValue="" alwaysStopAt="true"/>
        <variable name="obj" expression="guessElementType(Container)" defaultValue="camelCase(Clazz)"
                  alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="sb" value="StringBuilder $VAR1$ = new StringBuilder();
 $END$" shortcut="ENTER"
              description="新建StringBuilder" toReformat="true" toShortenFQNames="true">
        <variable name="VAR1" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="buff" value="StringBuffer $VAR$ = new StringBuffer();
" shortcut="ENTER"
              description="新建StringBuffer" toReformat="true" toShortenFQNames="true">
        <variable name="VAR" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="value" value="@Value("${$VAR1$}")
private $TYPE$ $VAR2$;
$END$
"
              shortcut="ENTER" description="新建value" toReformat="true" toShortenFQNames="true">
        <variable name="VAR1" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="TYPE" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="VAR2" expression="camelCase(VAR1)" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="st" value="String $VAR$=$END$;" shortcut="ENTER" description="new String" toReformat="true"
              toShortenFQNames="true">
        <variable name="VAR" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="nl" value="List<$TYPE$> $VAR$ = new ArrayList<>();
$END$" shortcut="ENTER"
              description="新建list" toReformat="true" toShortenFQNames="true">
        <variable name="TYPE" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="VAR" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="ns" value="Set<$TYPE$> $VAR$ = new HashSet<>();
$END$" shortcut="ENTER"
              description="新建set" toReformat="true" toShortenFQNames="true">
        <variable name="TYPE" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="VAR" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="nm" value="Map<$TYPE$> $VAR$ = new HashMap<>(4);
$END$" shortcut="ENTER"
              description="新建map" toReformat="true" toShortenFQNames="true">
        <variable name="TYPE" expression="" defaultValue="" alwaysStopAt="true"/>
        <variable name="VAR" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
    <template name="forii" value="for(int i=0,len=$VAR$;i<len;i++){
    $END$
}
" shortcut="ENTER"
              description="Create  new iteration Loop" toReformat="true" toShortenFQNames="true">
        <variable name="VAR" expression="" defaultValue="" alwaysStopAt="true"/>
        <context>
            <option name="JAVA_CODE" value="true"/>
        context>
    template>
templateSet>

你可能感兴趣的:(IntelliJ,IDEA,intellij-idea,java)