mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-22 06:21:25 +07:00
[javadoc inspection]: test "MissingJavadoc" inspection
GitOrigin-RevId: 1bf6991891b8fb26a67c3f9f94f2a230ce030735
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b8ce6d3e04
commit
15dfb6342e
@@ -0,0 +1,29 @@
|
||||
package sample;
|
||||
|
||||
public class AllDisabled {
|
||||
|
||||
public int x = 42;
|
||||
private int y = 42;
|
||||
|
||||
public int getX(){
|
||||
return x;
|
||||
}
|
||||
|
||||
public void test1(int param) {
|
||||
}
|
||||
|
||||
private String test2(int param) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String test3(int param) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
static class Inner1 {
|
||||
}
|
||||
|
||||
private static class Inner2 {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package sample;
|
||||
|
||||
public class <warning descr="Required Javadoc is absent">ClassEnabled</warning> {
|
||||
|
||||
public int x = 42;
|
||||
private int y = 42;
|
||||
|
||||
public int getX(){
|
||||
return x;
|
||||
}
|
||||
|
||||
public void test1(int param) {
|
||||
}
|
||||
|
||||
protected String test2(int param) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String test3(int param) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
public static class Inner1 {
|
||||
}
|
||||
|
||||
private static class Inner2 {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package sample;
|
||||
|
||||
public class FieldEnabled {
|
||||
|
||||
public int <warning descr="Required Javadoc is absent">x</warning> = 42;
|
||||
private int y = 42;
|
||||
|
||||
public int getX(){
|
||||
return x;
|
||||
}
|
||||
|
||||
public void test1(int param) {
|
||||
}
|
||||
|
||||
protected String test2(int param) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String test3(int param) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
public static class Inner1 {
|
||||
}
|
||||
|
||||
private static class Inner2 {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package sample;
|
||||
|
||||
public class InnerClassEnabled {
|
||||
|
||||
public int x = 42;
|
||||
private int y = 42;
|
||||
|
||||
public int getX(){
|
||||
return x;
|
||||
}
|
||||
|
||||
public void test1(int param) {
|
||||
}
|
||||
|
||||
protected String test2(int param) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String test3(int param) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
public static class <warning descr="Required Javadoc is absent">Inner1</warning> {
|
||||
}
|
||||
|
||||
private static class Inner2 {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package sample;
|
||||
|
||||
public class MethodEnabled {
|
||||
|
||||
public int x = 42;
|
||||
private int y = 42;
|
||||
|
||||
public int <warning descr="Required Javadoc is absent">getX</warning>(){
|
||||
return x;
|
||||
}
|
||||
|
||||
public void <warning descr="Required Javadoc is absent">test1</warning>(int param) {
|
||||
}
|
||||
|
||||
protected String test2(int param) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String <warning descr="Required Javadoc is absent">test3</warning>(int param) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
public static class Inner1 {
|
||||
}
|
||||
|
||||
private static class Inner2 {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package sample;
|
||||
|
||||
public class MethodIgnored {
|
||||
|
||||
public int x = 42;
|
||||
private int y = 42;
|
||||
|
||||
public int getX(){
|
||||
return x;
|
||||
}
|
||||
|
||||
public void <warning descr="Required Javadoc is absent">test1</warning>(int param) {
|
||||
}
|
||||
|
||||
protected String <warning descr="Required Javadoc is absent">test2</warning>(int param) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String test3(int param) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
public static class Inner1 {
|
||||
}
|
||||
|
||||
private static class Inner2 {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package sample;
|
||||
|
||||
public class PrivateFieldEnabled {
|
||||
public int <warning descr="Required Javadoc is absent">x</warning> = 42;
|
||||
private int <warning descr="Required Javadoc is absent">y</warning> = 42;
|
||||
|
||||
public int getX(){
|
||||
return x;
|
||||
}
|
||||
|
||||
public void test1(int param) {
|
||||
}
|
||||
|
||||
protected String test2(int param) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String test3(int param) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
public static class Inner1 {
|
||||
}
|
||||
|
||||
private static class Inner2 {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package sample;
|
||||
|
||||
public class PrivateMethodEnabled {
|
||||
|
||||
public int x = 42;
|
||||
private int y = 42;
|
||||
|
||||
public int <warning descr="Required Javadoc is absent">getX</warning>(){
|
||||
return x;
|
||||
}
|
||||
|
||||
public void <warning descr="Required Javadoc is absent">test1</warning>(int param) {
|
||||
}
|
||||
|
||||
protected String <warning descr="Required Javadoc is absent">test2</warning>(int param) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String <warning descr="Required Javadoc is absent">test3</warning>(int param) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
public static class Inner1 {
|
||||
}
|
||||
|
||||
private static class Inner2 {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package sample;
|
||||
|
||||
public class ProtectedInnerClassEnabled {
|
||||
|
||||
public int x = 42;
|
||||
private int y = 42;
|
||||
|
||||
public int getX(){
|
||||
return x;
|
||||
}
|
||||
|
||||
public void test1(int param) {
|
||||
}
|
||||
|
||||
protected String test2(int param) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String test3(int param) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
public static class <warning descr="Required Javadoc is absent">Inner1</warning> {
|
||||
}
|
||||
|
||||
protected static class <warning descr="Required Javadoc is absent">Inner2</warning> {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package sample;
|
||||
|
||||
public class PublicMemberInPrivateClass {
|
||||
|
||||
public int <warning descr="Required Javadoc is absent">x</warning> = 42;
|
||||
public String <warning descr="Required Javadoc is absent">test1</warning>(int param) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
private static class Inner2 {
|
||||
public int y = 42;
|
||||
public String test2(int param) {
|
||||
return "42";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package sample;
|
||||
|
||||
<warning descr="Required tag '@author' is missing"><warning descr="Required tag '@param' is missing for parameter '<T>'">/**</warning></warning>
|
||||
*
|
||||
*/
|
||||
public class RequiredTags<T> {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void empty(){
|
||||
}
|
||||
|
||||
<warning descr="Required tag '@param' is missing for parameter 'param'"><warning descr="Required tag '@return' is missing"><warning descr="Required tag '@throws' java.lang.RuntimeException is missing">/**</warning></warning></warning>
|
||||
*
|
||||
*/
|
||||
public int full(int param) throws RuntimeException{
|
||||
return 42;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<error descr="Module declaration should be located in a module's source root">module Disabled</error> { }
|
||||
@@ -0,0 +1 @@
|
||||
<error descr="Module declaration should be located in a module's source root">module <warning descr="Required Javadoc is absent">Enabled</warning></error> { }
|
||||
@@ -0,0 +1 @@
|
||||
<error descr="Module declaration should be located in a module's source root">module <warning descr="Required Javadoc is absent">Enabled</warning></error> { }
|
||||
@@ -0,0 +1 @@
|
||||
package disabled;
|
||||
@@ -0,0 +1 @@
|
||||
<warning descr="Required Javadoc is absent">package enabled;</warning>
|
||||
@@ -0,0 +1,4 @@
|
||||
<warning descr="Required tag '@author' is missing">/**</warning>
|
||||
*
|
||||
*/
|
||||
package requiredTags;
|
||||
@@ -0,0 +1,125 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.java.codeInsight.daemon;
|
||||
|
||||
import com.intellij.codeInspection.javaDoc.MissingJavadocInspection;
|
||||
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase5;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class MissingJavadocHighlightingTest extends LightJavaCodeInsightFixtureTestCase5 {
|
||||
|
||||
private MissingJavadocInspection myInspection;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
MissingJavadocInspection inspection = new MissingJavadocInspection();
|
||||
getFixture().enableInspections(inspection);
|
||||
myInspection = inspection;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull String getRelativePath() {
|
||||
return super.getRelativePath() + "/codeInsight/daemonCodeAnalyzer/missingJavadoc/";
|
||||
}
|
||||
|
||||
@Test void testAllDisabled(){
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Test void testMethodEnabled(){
|
||||
myInspection.methodOptions.isEnabled = true;
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Test void testPrivateMethodEnabled(){
|
||||
myInspection.methodOptions.isEnabled = true;
|
||||
myInspection.methodOptions.minimalVisibility = "private";
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Test void testMethodIgnored(){
|
||||
myInspection.methodOptions.isEnabled = true;
|
||||
myInspection.methodOptions.minimalVisibility = "private";
|
||||
myInspection.ignoreDeprecated = true;
|
||||
myInspection.ignoreAccessors = true;
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Test void testPublicMemberInPrivateClass(){
|
||||
myInspection.methodOptions.isEnabled = true;
|
||||
myInspection.methodOptions.minimalVisibility = "public";
|
||||
myInspection.fieldOptions.isEnabled = true;
|
||||
myInspection.fieldOptions.minimalVisibility = "public";
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Test void testClassEnabled(){
|
||||
myInspection.topLevelClassOptions.isEnabled = true;
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Test void testFieldEnabled(){
|
||||
myInspection.fieldOptions.isEnabled = true;
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Test void testPrivateFieldEnabled(){
|
||||
myInspection.fieldOptions.isEnabled = true;
|
||||
myInspection.fieldOptions.minimalVisibility = "private";
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Test void testInnerClassEnabled(){
|
||||
myInspection.innerClassOptions.isEnabled = true;
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Test void testProtectedInnerClassEnabled(){
|
||||
myInspection.innerClassOptions.isEnabled = true;
|
||||
myInspection.innerClassOptions.minimalVisibility = "protected";
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Test void testRequiredTags(){
|
||||
myInspection.topLevelClassOptions.isEnabled = true;
|
||||
myInspection.topLevelClassOptions.setTagRequired("author", true);
|
||||
myInspection.topLevelClassOptions.setTagRequired("param", true);
|
||||
myInspection.methodOptions.isEnabled = true;
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Test void testPackageDisabled(){
|
||||
getFixture().testHighlighting("/packageInfo/disabled/package-info.java");
|
||||
}
|
||||
|
||||
@Test void testPackageEnabled(){
|
||||
myInspection.packageOptions.isEnabled = true;
|
||||
getFixture().testHighlighting("/packageInfo/enabled/package-info.java");
|
||||
}
|
||||
|
||||
@Test void testPackageRequiredTags(){
|
||||
myInspection.packageOptions.isEnabled = true;
|
||||
myInspection.packageOptions.setTagRequired("author", true);
|
||||
getFixture().testHighlighting("/packageInfo/requiredTags/package-info.java");
|
||||
}
|
||||
|
||||
@Test void testModuleDisabled(){
|
||||
getFixture().testHighlighting("/moduleInfo/disabled/module-info.java");
|
||||
}
|
||||
|
||||
@Test void testModuleEnabled(){
|
||||
myInspection.moduleOptions.isEnabled = true;
|
||||
getFixture().testHighlighting("/moduleInfo/enabled/module-info.java");
|
||||
}
|
||||
|
||||
@Test void testModuleRequiredTags(){
|
||||
myInspection.moduleOptions.isEnabled = true;
|
||||
myInspection.moduleOptions.setTagRequired("author", true);
|
||||
getFixture().testHighlighting("/moduleInfo/requiredTags/module-info.java");
|
||||
}
|
||||
|
||||
private void doTest(){
|
||||
getFixture().testHighlighting(getTestName(false) + ".java");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user