Don't warn about missing tag description on void methods

GitOrigin-RevId: 7125c41e5adfb4a45f96b6f5c9b6db12a9a0da6d
This commit is contained in:
Andrey.Cherkasov
2020-11-20 21:10:26 +03:00
committed by intellij-monorepo-bot
parent ea5b5de628
commit 1a75f19cff
4 changed files with 12 additions and 3 deletions

View File

@@ -326,7 +326,7 @@ public class JavaDocLocalInspection extends LocalInspectionTool {
}
if (!myIgnoreEmptyDescriptions) {
JavadocHighlightUtil.checkEmptyMethodTagsDescription(tags, holder);
JavadocHighlightUtil.checkEmptyMethodTagsDescription(tags, method, holder);
}
checkBasics(docComment, tags, method, false, METHOD_OPTIONS, holder);

View File

@@ -438,14 +438,16 @@ public final class JavadocHighlightUtil {
}
}
static void checkEmptyMethodTagsDescription(PsiDocTag @NotNull [] tags, @NotNull ProblemHolder holder) {
static void checkEmptyMethodTagsDescription(PsiDocTag @NotNull [] tags,
@NotNull PsiMethod psiMethod,
@NotNull ProblemHolder holder) {
for (PsiDocTag tag : tags) {
if (ContainerUtil
.exists(tag.getChildren(), e -> e instanceof PsiInlineDocTag && ((PsiInlineDocTag)e).getName().equals("inheritDoc"))) {
continue;
}
if ("return".equals(tag.getName())) {
if (emptyTag(tag)) {
if (!PsiType.VOID.equals(psiMethod.getReturnType()) && emptyTag(tag)) {
String tagText = "<code>@return</code>";
LocalQuickFix fix = holder.removeTagWithoutDescriptionFix("return");
holder.problem(tag.getNameElement(), JavaBundle.message("inspection.javadoc.method.problem.missing.tag.description", tagText), fix);