diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties index 8ef5de25f0bb..448bb47c1481 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties @@ -1717,11 +1717,12 @@ listener.may.use.adapter.display.name=Class may extend adapter instead of implem listener.may.use.adapter.problem.descriptor=Class ''{0}'' may extend ''{1}'' instead of implementing #ref #loc listener.may.use.adapter.quickfix=Replace with ''extends {0}'' listener.may.use.adapter.emtpy.methods.option=&Only warn when empty implementing methods are found -unnecessary.inherit.doc.display.name=Unnecessary {@inheritDoc} Javadoc Comment +unnecessary.inherit.doc.display.name=Unnecessary {@inheritDoc} Javadoc comment unnecessary.inherit.doc.problem.descriptor=Javadoc comment containing only #ref is unnecessary #loc unnecessary.inherit.doc.field.invalid.problem.descriptor=#ref is not valid on fields #loc unnecessary.inherit.doc.constructor.invalid.problem.descriptor=#ref is not valid on constructors #loc unnecessary.inherit.doc.class.invalid.problem.descriptor=#ref is not valid on classes #loc +unnecessary.inherit.doc.module.invalid.problem.descriptor=#ref is not valid on module declarations #loc unnecessary.inherit.doc.constructor.no.super.problem.descriptor=No super method found to inherit Javadoc from #loc unnecessary.inherit.doc.quickfix=Remove unnecessary {@inheritDoc} multiple.exceptions.declared.on.test.method.display.name=Multiple exceptions declared on test method diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/javadoc/UnnecessaryInheritDocInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/javadoc/UnnecessaryInheritDocInspection.java index d5eabbae501b..b8713e85b242 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/javadoc/UnnecessaryInheritDocInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/javadoc/UnnecessaryInheritDocInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2015 Bas Leijdekkers + * Copyright 2009-2017 Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,14 +39,15 @@ public class UnnecessaryInheritDocInspection extends BaseInspection { @NotNull @Override public String getDisplayName() { - return InspectionGadgetsBundle.message( - "unnecessary.inherit.doc.display.name"); + return InspectionGadgetsBundle.message("unnecessary.inherit.doc.display.name"); } @NotNull @Override protected String buildErrorString(Object... infos) { switch ((WarningType)infos[0]) { + case MODULE: + return InspectionGadgetsBundle.message("unnecessary.inherit.doc.module.invalid.problem.descriptor"); case CLASS: return InspectionGadgetsBundle.message("unnecessary.inherit.doc.class.invalid.problem.descriptor"); case FIELD: @@ -63,7 +64,7 @@ public class UnnecessaryInheritDocInspection extends BaseInspection { } enum WarningType { - CLASS, FIELD, CONSTRUCTOR, EMPTY, NO_SUPER + MODULE, CLASS, FIELD, CONSTRUCTOR, EMPTY, NO_SUPER } @Override @@ -129,6 +130,10 @@ public class UnnecessaryInheritDocInspection extends BaseInspection { return; } final PsiJavaDocumentedElement owner = docComment.getOwner(); + if (owner instanceof PsiJavaModule) { + registerError(tag, WarningType.MODULE); + return; + } if (owner instanceof PsiField) { registerError(tag, WarningType.FIELD); return; diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryInheritDoc.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryInheritDoc.html index 4136b99d9c74..34a65b7a9d5e 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryInheritDoc.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryInheritDoc.html @@ -1,10 +1,10 @@ -Reports any Javadoc comments which contain only the -{@inheritDoc} +Reports any Javadoc comments which contain only the {@inheritDoc} tag. Since Javadoc copies the super class' comment if no comment is present, a -comment containing only an {@inheritDoc} -adds nothing. +comment containing only an {@inheritDoc} adds nothing. +

+Also reports {@inheritDoc} usages in invalid locations, for example on fields.

diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/javadoc/unnecessary_inherit_doc/module-info.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/javadoc/unnecessary_inherit_doc/module-info.java new file mode 100644 index 000000000000..c491fcfed750 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/javadoc/unnecessary_inherit_doc/module-info.java @@ -0,0 +1,6 @@ +/** + * {@inheritDoc} + */ +module com.inherit.doc.test.test.test { + +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/javadoc/UnnecessaryInheritDocInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/javadoc/UnnecessaryInheritDocInspectionTest.java index 1f31c59361ff..ed038ff04e30 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/javadoc/UnnecessaryInheritDocInspectionTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/javadoc/UnnecessaryInheritDocInspectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,9 @@ package com.siyeh.ig.javadoc; import com.intellij.codeInspection.InspectionProfileEntry; +import com.intellij.testFramework.LightProjectDescriptor; import com.siyeh.ig.LightInspectionTestCase; +import org.jetbrains.annotations.NotNull; public class UnnecessaryInheritDocInspectionTest extends LightInspectionTestCase { @@ -24,8 +26,18 @@ public class UnnecessaryInheritDocInspectionTest extends LightInspectionTestCase doTest(); } + public void testModuleInfo() { + doNamedTest("module-info"); + } + @Override protected InspectionProfileEntry getInspection() { return new UnnecessaryInheritDocInspection(); } + + @NotNull + @Override + protected LightProjectDescriptor getProjectDescriptor() { + return JAVA_9; + } }