[英]Why does IntelliJ IDEA give a warning that this file javadoc is dangling?
I'm using IntelliJ IDEA and I tried to add a Javadoc comment at the top of the file like this:我正在使用 IntelliJ IDEA,并尝试在文件顶部添加一个 Javadoc 注释,如下所示:
/**
* @file ProcessJson.java
* @author Tim Sloane
* @date 2017-05-09
*/
But IntelliJ gives me the warning "Dangling Javadoc comment."但是 IntelliJ 给了我警告“悬空的 Javadoc 评论”。 What makes this comment dangling?
是什么让这条评论悬而未决? I thought because it's tagged with @file, it should be at the start of the file.
我想因为它用@file 标记,所以它应该在文件的开头。
You will also see this if you placed the Javadoc comment after any annotations.如果您将 Javadoc 注释放在任何注释之后,您也会看到这一点。
For example:例如:
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@SuppressWarnings({"unused", "WeakerAccess"})
/** --> Dangling Javadoc warning.
* This class does great and wonderful things.
*/
public class ClassThatDoesStuff {
}
Instead, the Javadoc must precede everything to receive the "No errors found in this file" seal of approval:相反,Javadoc 必须先于一切才能收到“在此文件中未发现错误”的批准印章:
/**
* This class does great and wonderful things.
*/
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@SuppressWarnings({"unused", "WeakerAccess"})
public class ClassThatDoesStuff {
}
Just in case, if you are interested in removing this dangling JavaDoc comment inspection, you can do so by disabling that from:以防万一,如果您有兴趣删除这个悬空的 JavaDoc 注释检查,您可以通过以下方式禁用它:
Javadoc has no @file or @date tags. Javadoc 没有 @file 或 @date 标签。 You should be tagging the class, instead.
相反,您应该标记课程。
/**
* Description of the class goes here.
*
* @author Tim Sloane
*/
public class ProcessJson {
See:看:
http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html
https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html
Take a bit of time to read the expanded help for this warning, emphasis mine:花一点时间阅读此警告的扩展帮助,重点是我的:
Reports dangling Javadoc comments.
报告悬空的 Javadoc 注释。 Javadoc comments are dangling if they don't belong to any class, method or field.
如果 Javadoc 注释不属于任何类、方法或字段,则它们是悬空的。 For example a Javadoc comment in between method declarations that have their own Javadoc comments.
例如,在具有自己的 Javadoc 注释的方法声明之间的 Javadoc 注释。
Your Javadoc comment doesn't belong to the class, or a method, or a field, so it's indeed dangling.您的 Javadoc 注释不属于类、方法或字段,因此它确实悬而未决。 The
@file
tag doesn't exist , so it's superfluous to add at all. @file
标签不存在,所以添加是多余的。
Alternatively, you could remove one asterisk and not have Javadoc, and thus silence IntelliJ on the matter...或者,您可以删除一个星号而不使用 Javadoc,从而使 IntelliJ 保持沉默...
Intellij Idea gives you the warning of " Dangling Javadoc comment ", Intellij Idea 给你“ Dangling Javadoc comment ”的警告,
1-If you insert you classes import declarations after Javadoc
: 1-如果在
Javadoc
之后插入类导入声明:
/**
* @author Elyas 'Eloy' Hadizadeh Tasbiti
* Created in 3/16/20, 1:15 PM.
*/
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/")
public class HomeController
{}
2-If you put your Javadoc comments after class-level annotations: 2-如果您将 Javadoc 注释放在类级注释之后:
@Controller
@RequestMapping("/")
/**
* @author Elyas 'Eloy' Hadizadeh Tasbiti
* Created in 3/16/20, 1:15 PM.
*/
public class HomeController
{}
3-If you use inappropriate tags such as @file
or @date
which are not understandable by JavaDoc. 3-如果您使用了 JavaDoc 无法理解的不当标签,例如
@file
或@date
。
Although you can skip these warnings or change a Java-doc comment to a regular comment by omitting one of the asterisks from the first line, I highly recommend using Java-docs which soon can be very helpful and generates standard documentation in HTML.尽管您可以通过省略第一行中的一个星号来跳过这些警告或将 Java-doc 注释更改为常规注释,但我强烈建议使用 Java-docs,它很快就会非常有用并生成 HTML 格式的标准文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.