当前位置: 首页 > news >正文

idea java 注释模板_IDEA添加Java类注释模版的方法

本文介绍了IDEA添加Java类注释模版的方法,分享给大家,具体如下:

IDEA版本:IntelliJ IDEA 2017.2.5 x64

eclipse能在类上方输入/**,回车添加类注释模版,但idea没有默认添加这个功能,需要做一些设置。下面介绍三种方法实现:

创建类默认添加类注释

手动添加类注释

批量添加JavaDoc注释

一、设置新建类默认添加注释

依次点击Setting|Editor|File and code templates,添加如图配置

例子:

/**

*describe:

*

*@author xxx

*@date ${YEAR}/${MONTH}/${DAY}

*/

支持的变量在描述内,找到需要配置即可!

二、利用Live Template手动添加注释模版

依次点击Setting|Editor|Live templates

1、点击+添加templates group,如My Live Templates

2、点击+添加live templates,修改abbreviation,再添加模版内容,模版变量以$var$格式定义,如

/**

*describe:

*

*@author xxx

*@date $date$

*/

3. 点击define定义模版作用范围,选择Java

4. 点击Edit variables定义变量,表达式解释见附件

5. 保存后,在类任意位置输入cc即可添加模版

三、批量添加注释

安装JavaDoc插件,alt+insert即可批量添加注释,包括所有类和方法,但是不能定制化,注释都是固定的。

附件

Item

Description

annotated("annotation qname")

Creates a symbol of type with an annotation that resides at the specified location. For an example, see Live Templates in the iterations group.

arrayVariable()

Suggests all array variables applicable in the current scope. For an example, see Live Templates in the iterations group.

anonymousSuper()

Suggests a supertype for a Kotlin object expression.

camelCase(String)

Returns the string passed as a parameter, converted to camel case. For example, my-text-file/my text file/my_text_file will be converted to myTextFile.

capitalize(String)

Capitalizes the first letter of the name passed as a parameter.

capitalizeAndUnderscore(sCamelCaseName)

Capitalizes the all letters of a CamelCase name passed as a parameter, and inserts an underscore between the parts. For example, if the string passed as a parameter is FooBar, then the function returns FOO_BAR.

castToLeftSideType()

Casts the right-side expression to the left-side expression type. It is used in the iterations group to have a single template for generating both raw-type and Generics Collections.

className(sClassName)

Returns the name of the current class (the class where the template is expanded).

classNameComplete()

This expression substitutes for the class name completion at the variable position.

clipboard()

Returns the contents of the system clipboard.

snakeCase(String)

Returns CamelCase string out of snake_case string. For example, if the string passed as a parameter is foo_bar, then the function returns fooBar.

complete()

This expression substitutes for the code completion invocation at the variable position.

completeSmart()

This expression substitutes for the smart type completion invocation at the variable position.

componentTypeOf ()

Returns component type of an array. For example, see the Live Templates in the iterations group in the other group.

currentPackage()

Returns the current package name.

date(sDate)

Returns the current system date in the specified format.

By default, the current date is returned in the default system format. However, if you specify date format in double quotes, the date will be presented in this format:

decapitalize(sName)

Replaces the first letter of the name passed as a parameter with the corresponding lowercase letter.

descendantClassEnum()

Shows the children of the class entered as a string parameter.

enum(sCompletionString1,sCompletionString2,...)

List of comma-delimited strings suggested for completion at the template invocation.

escapeString(sEscapeString)

Escapes the specified string.

expectedType()

Returns the type which is expected as a result of the whole template. Makes sense if the template is expanded in the right part of an assignment, after return, etc.

fileName(sFileName)

Returns file name with extension.

fileNameWithoutExtension()

Returns file name without extension.

firstWord(sFirstWord)

Returns the first word of the string passed as a parameter.

groovyScript("groovy code")

Returns Groovy script with the specified code.

You can use groovyScript macro with multiple arguments. The first argument is a script text that is executed or a path to the file that contains a script. The next arguments are bound to _1, _2, _3, ..._nvariables that are available inside your script.

Also, _editor variable is available inside the script. This variable is bound to the current editor.

guessElementType ()

Makes a guess on the type of elements stored in a java.util.Collection. To make a guess, IntelliJ IDEA tries to find the places where the elements were added to or extracted from the container.

iterableComponentType()

Returns the type of an iterable component, such as an array or a collection.

iterableVariable()

Returns the name of a variable that can be iterated.

lineNumber()

Returns the current line number.

lowercaseAndDash(String)

Returns lower case separated by dashes, of the string passed as a parameter. For example, the string MyExampleName is converted to my-example-name.

methodName()

Returns the name of the embracing method (where the template is expanded).

methodParameters()

Returns the list of parameters of the embracing method (where the template is expanded).

methodReturnType()

Returns the type of the value returned by the current method (the method within which the template is expanded).

qualifiedClassName()

Returns the fully qualified name of the current class (the class where the template is expanded).

Clear the Shorten FQ names check box.

rightSideType()

Declares the left-side variable with a type of the right-side expression. It is used in theiterations group to have a single template for generating both raw-type and Generics Collections.

snakeCase(sCamelCaseText)

Returns snake_case string out of CamelCase string passed as a parameter.

spaceSeparated(String)

Returns string separated with spaces out of CamelCase string passed as a parameter. For example, if the string passed as a parameter is fooBar, then the function returns foo bar.

subtypes(sType)

Returns the subtypes of the type passed as a parameter.

suggestIndexName()

Suggests the name of an index variable. Returns i if there is no such variable in scope, otherwise returns j if there is no such variable in scope, etc.

suggestVariableName()

Suggests the name for a variable based on the variable type and its initializer expression, according to your code style settings that refer to the variable naming rules.

For example, if it is a variable that holds an element within iteration, IntelliJ IDEA makes a guess on the most reasonable names, also taking into account the name of the container being iterated.

suggestFirstVariableName(sFirstVariableName)

Doesn't suggest true, false, this, super.

time(sSystemTime)

Returns the current system time.

typeOfVariable(VAR)

Returns the type of the variable passed as a parameter.

underscoresToCamelCase(sCamelCaseText)

Returns the string passed as a parameter with CamelHump letters substituting for underscores. For example, if the string passed as a parameter is foo_bar, then the function returns fooBar.

underscoresToSpaces(sParameterWithSpaces)

Returns the string passed as a parameter with spaces substituting for underscores.

user()

Returns the name of the current user.

variableOfType()

Suggests all variables that may be assigned to the type passed as a parameter, for example variableOfType("java.util.Vector"). If you pass an empty string ("") as a parameter, suggests all variables regardless of their types.

JsArrayVariable

Returns JavaScript array name.

jsClassName()

Returns the name of the current JavaScript class.

jsComponentType

Returns the JavaScript component type.

jsMethodName()

Returns the name of the current JavaScript method.

jsQualifiedClassName

Returns the complete name of the current JavaScript class.

jsSuggestIndexName

Returns a suggested name for an index.

jsSuggestVariableName

Returns a suggested name for a variable.

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

相关文章:

  • java中数组问题_java中数组的数组问题
  • Java中implies_Java FilePermission.implies(Permission p)示例
  • java8 计算时间差_java8-计算时间差的方法
  • java 编写shuffle方法_在java中为播放列表创建一个shuffle方法
  • java call by value_Java的call by value和call by reference的详细介绍
  • java udp jframe_java实现UDP通信
  • java代码执行顺序_Java基础-代码执行顺序(重要)
  • java jlist 添加滚动条_jlist的滚动条报错
  • matchcollection java_JAVA collection集合之扑克牌游戏实例
  • java 封闭实例_java – 不能访问类型为Server的封闭实例
  • ip 十进制 整型 java_java IP地址与十进制转换
  • java text只读_设置Edit Text只读
  • mysql 工具里直接修改sql结果数据_navicat for Mysql查询数据不能直接修改
  • python again语句_Python语句
  • java评卷系统_GitHub - Ju5ticeGit/ExamSym: 基于java的考试及阅卷系统
  • Cumulo 的 ClojureScript 模块已经成型
  • Javascripit类型转换比较那点事儿,双等号(==)
  • JavaScript DOM 10 - 滚动
  • JavaScript设计模式系列一:工厂模式
  • Java深入 - 深入理解Java集合
  • JDK 6和JDK 7中的substring()方法
  • quasar-framework cnodejs社区
  • Spark VS Hadoop:两大大数据分析系统深度解读
  • Theano - 导数
  • TiDB 源码阅读系列文章(十)Chunk 和执行框架简介
  • 阿里云ubuntu14.04 Nginx反向代理Nodejs
  • 从零开始学习部署
  • 订阅Forge Viewer所有的事件
  • 短视频宝贝=慢?阿里巴巴工程师这样秒开短视频
  • 将回调地狱按在地上摩擦的Promise
  • 每天10道Java面试题,跟我走,offer有!
  • 扑朔迷离的属性和特性【彻底弄清】
  • 三栏布局总结
  • 说说动画卡顿的解决方案
  • 职业生涯 一个六年开发经验的女程序员的心声。
  • 字符串匹配基础上
  • 自制字幕遮挡器
  • python最赚钱的4个方向,你最心动的是哪个?
  • 宾利慕尚创始人典藏版国内首秀,2025年前实现全系车型电动化 | 2019上海车展 ...
  • #常见电池型号介绍 常见电池尺寸是多少【详解】
  • (c语言版)滑动窗口 给定一个字符串,只包含字母和数字,按要求找出字符串中的最长(连续)子串的长度
  • (补)B+树一些思想
  • (二)什么是Vite——Vite 和 Webpack 区别(冷启动)
  • (非本人原创)史记·柴静列传(r4笔记第65天)
  • (转)为C# Windows服务添加安装程序
  • (总结)Linux下的暴力密码在线破解工具Hydra详解
  • ***微信公众号支付+微信H5支付+微信扫码支付+小程序支付+APP微信支付解决方案总结...
  • .L0CK3D来袭:如何保护您的数据免受致命攻击
  • .NET Core实战项目之CMS 第十二章 开发篇-Dapper封装CURD及仓储代码生成器实现
  • .net遍历html中全部的中文,ASP.NET中遍历页面的所有button控件
  • .net实现头像缩放截取功能 -----转载自accp教程网
  • .NET项目中存在多个web.config文件时的加载顺序
  • /boot 内存空间不够
  • /usr/bin/perl:bad interpreter:No such file or directory 的解决办法
  • @AutoConfigurationPackage的使用