Search in sources :

Example 1 with JavaDocLocalInspection

use of com.intellij.codeInspection.javaDoc.JavaDocLocalInspection in project intellij-community by JetBrains.

the class JavaDocCommentFixer method getDocLocalInspection.

@NotNull
private static JavaDocLocalInspection getDocLocalInspection() {
    JavaDocLocalInspection localInspection = new JavaDocLocalInspection();
    //region visibility
    localInspection.TOP_LEVEL_CLASS_OPTIONS.ACCESS_JAVADOC_REQUIRED_FOR = PsiModifier.PRIVATE;
    localInspection.INNER_CLASS_OPTIONS.ACCESS_JAVADOC_REQUIRED_FOR = PsiModifier.PRIVATE;
    localInspection.FIELD_OPTIONS.ACCESS_JAVADOC_REQUIRED_FOR = PsiModifier.PRIVATE;
    localInspection.METHOD_OPTIONS.ACCESS_JAVADOC_REQUIRED_FOR = PsiModifier.PRIVATE;
    //endregion
    localInspection.setIgnoreEmptyDescriptions(true);
    //region class type arguments
    if (!localInspection.TOP_LEVEL_CLASS_OPTIONS.REQUIRED_TAGS.contains(PARAM_TAG)) {
        localInspection.TOP_LEVEL_CLASS_OPTIONS.REQUIRED_TAGS += PARAM_TAG;
    }
    if (!localInspection.INNER_CLASS_OPTIONS.REQUIRED_TAGS.contains(PARAM_TAG)) {
        localInspection.INNER_CLASS_OPTIONS.REQUIRED_TAGS += PARAM_TAG;
    }
    return localInspection;
}
Also used : JavaDocLocalInspection(com.intellij.codeInspection.javaDoc.JavaDocLocalInspection) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with JavaDocLocalInspection

use of com.intellij.codeInspection.javaDoc.JavaDocLocalInspection in project intellij-community by JetBrains.

the class JavaDocCommentFixer method fixComment.

@Override
public void fixComment(@NotNull Project project, @NotNull Editor editor, @NotNull PsiComment comment) {
    if (!(comment instanceof PsiDocComment)) {
        return;
    }
    PsiDocComment docComment = (PsiDocComment) comment;
    PsiJavaDocumentedElement owner = docComment.getOwner();
    if (owner == null) {
        return;
    }
    PsiFile file = comment.getContainingFile();
    if (file == null) {
        return;
    }
    JavaDocReferenceInspection referenceInspection = new JavaDocReferenceInspection();
    JavaDocLocalInspection localInspection = getDocLocalInspection();
    InspectionManager inspectionManager = InspectionManager.getInstance(project);
    ProblemDescriptor[] referenceProblems = null;
    ProblemDescriptor[] otherProblems = null;
    if (owner instanceof PsiClass) {
        referenceProblems = referenceInspection.checkClass(((PsiClass) owner), inspectionManager, false);
        otherProblems = localInspection.checkClass(((PsiClass) owner), inspectionManager, false);
    } else if (owner instanceof PsiField) {
        referenceProblems = referenceInspection.checkField(((PsiField) owner), inspectionManager, false);
        otherProblems = localInspection.checkField(((PsiField) owner), inspectionManager, false);
    } else if (owner instanceof PsiMethod) {
        referenceProblems = referenceInspection.checkMethod((PsiMethod) owner, inspectionManager, false);
        otherProblems = localInspection.checkMethod((PsiMethod) owner, inspectionManager, false);
    }
    if (referenceProblems != null) {
        fixReferenceProblems(referenceProblems, project);
    }
    if (otherProblems != null) {
        fixCommonProblems(otherProblems, comment, editor.getDocument(), project);
    }
    PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.getDocument());
    ensureContentOrdered(docComment, editor.getDocument());
    locateCaret(docComment, editor, file);
}
Also used : PsiDocComment(com.intellij.psi.javadoc.PsiDocComment) JavaDocReferenceInspection(com.intellij.codeInspection.javaDoc.JavaDocReferenceInspection) InspectionManager(com.intellij.codeInspection.InspectionManager) ProblemDescriptor(com.intellij.codeInspection.ProblemDescriptor) JavaDocLocalInspection(com.intellij.codeInspection.javaDoc.JavaDocLocalInspection)

Example 3 with JavaDocLocalInspection

use of com.intellij.codeInspection.javaDoc.JavaDocLocalInspection in project intellij-community by JetBrains.

the class LightAdvHighlightingTest method testJavadoc.

public void testJavadoc() {
    enableInspectionTool(new JavaDocLocalInspection());
    doTest(true);
}
Also used : JavaDocLocalInspection(com.intellij.codeInspection.javaDoc.JavaDocLocalInspection)

Example 4 with JavaDocLocalInspection

use of com.intellij.codeInspection.javaDoc.JavaDocLocalInspection in project intellij-community by JetBrains.

the class JavadocHighlightingTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.HIGHEST);
    myInspection = new JavaDocLocalInspection();
    myInspection.setIgnoreDuplicatedThrows(false);
    enableInspectionTools(myInspection, new JavaDocReferenceInspection());
}
Also used : JavaDocReferenceInspection(com.intellij.codeInspection.javaDoc.JavaDocReferenceInspection) JavaDocLocalInspection(com.intellij.codeInspection.javaDoc.JavaDocLocalInspection)

Example 5 with JavaDocLocalInspection

use of com.intellij.codeInspection.javaDoc.JavaDocLocalInspection in project intellij-community by JetBrains.

the class JavaDocInspectionTest method testPackageInfo.

public void testPackageInfo() {
    JavaDocLocalInspection inspection = new JavaDocLocalInspection();
    inspection.IGNORE_DEPRECATED = true;
    inspection.setPackageOption("public", "@author");
    myFixture.testInspection("packageInfo", new LocalInspectionToolWrapper(inspection));
}
Also used : LocalInspectionToolWrapper(com.intellij.codeInspection.ex.LocalInspectionToolWrapper) JavaDocLocalInspection(com.intellij.codeInspection.javaDoc.JavaDocLocalInspection)

Aggregations

JavaDocLocalInspection (com.intellij.codeInspection.javaDoc.JavaDocLocalInspection)6 JavaDocReferenceInspection (com.intellij.codeInspection.javaDoc.JavaDocReferenceInspection)2 NotNull (org.jetbrains.annotations.NotNull)2 InspectionManager (com.intellij.codeInspection.InspectionManager)1 LocalInspectionTool (com.intellij.codeInspection.LocalInspectionTool)1 ProblemDescriptor (com.intellij.codeInspection.ProblemDescriptor)1 LocalInspectionToolWrapper (com.intellij.codeInspection.ex.LocalInspectionToolWrapper)1 PsiDocComment (com.intellij.psi.javadoc.PsiDocComment)1