IG: check jdk9 modules too in "Unnecessary {@inheritDoc} Javadoc comment" inspection

This commit is contained in:
Bas Leijdekkers
2017-03-12 17:08:12 +01:00
parent ee4561a1da
commit 12c8edc10b
5 changed files with 34 additions and 10 deletions
@@ -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 <code>#ref</code> #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 <code>#ref</code> is unnecessary #loc
unnecessary.inherit.doc.field.invalid.problem.descriptor=<code>#ref</code> is not valid on fields #loc
unnecessary.inherit.doc.constructor.invalid.problem.descriptor=<code>#ref</code> is not valid on constructors #loc
unnecessary.inherit.doc.class.invalid.problem.descriptor=<code>#ref</code> is not valid on classes #loc
unnecessary.inherit.doc.module.invalid.problem.descriptor=<code>#ref</code> 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
@@ -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;
@@ -1,10 +1,10 @@
<html>
<body>
Reports any Javadoc comments which contain only the
<b>{@inheritDoc}</b>
Reports any Javadoc comments which contain only the <b>{@inheritDoc}</b>
tag. Since Javadoc copies the super class' comment if no comment is present, a
comment containing only an <b>{@inheritDoc}</b>
adds nothing.
comment containing only an <b>{@inheritDoc}</b> adds nothing.
<p>
Also reports <b>{@inheritDoc}</b> usages in invalid locations, for example on fields.
<!-- tooltip end -->
<p>
@@ -0,0 +1,6 @@
/**
* <warning descr="'{@inheritDoc}' is not valid on module declarations">{@inheritDoc}</warning>
*/
module com.inherit.doc.test.test.test {
}
@@ -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;
}
}