Search in sources :

Example 1 with JavaDocReferenceInspection

use of com.intellij.codeInspection.javaDoc.JavaDocReferenceInspection 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 2 with JavaDocReferenceInspection

use of com.intellij.codeInspection.javaDoc.JavaDocReferenceInspection 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 3 with JavaDocReferenceInspection

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

the class RedundantSuppressTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    myInspectionToolWrappers = new InspectionToolWrapper[] { new LocalInspectionToolWrapper(new JavaDocReferenceInspection()), new LocalInspectionToolWrapper(new I18nInspection()), new LocalInspectionToolWrapper(new RawUseOfParameterizedTypeInspection()), new GlobalInspectionToolWrapper(new EmptyMethodInspection()), new GlobalInspectionToolWrapper(new UnusedDeclarationInspection()) };
    myWrapper = new GlobalInspectionToolWrapper(new RedundantSuppressInspection() {

        @NotNull
        @Override
        protected InspectionToolWrapper[] getInspectionTools(PsiElement psiElement, @NotNull InspectionManager manager) {
            return myInspectionToolWrappers;
        }
    });
}
Also used : JavaDocReferenceInspection(com.intellij.codeInspection.javaDoc.JavaDocReferenceInspection) GlobalInspectionToolWrapper(com.intellij.codeInspection.ex.GlobalInspectionToolWrapper) I18nInspection(com.intellij.codeInspection.i18n.I18nInspection) RawUseOfParameterizedTypeInspection(com.siyeh.ig.migration.RawUseOfParameterizedTypeInspection) EmptyMethodInspection(com.intellij.codeInspection.emptyMethod.EmptyMethodInspection) LocalInspectionToolWrapper(com.intellij.codeInspection.ex.LocalInspectionToolWrapper) UnusedDeclarationInspection(com.intellij.codeInspection.deadCode.UnusedDeclarationInspection) NotNull(org.jetbrains.annotations.NotNull) GlobalInspectionToolWrapper(com.intellij.codeInspection.ex.GlobalInspectionToolWrapper) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper) LocalInspectionToolWrapper(com.intellij.codeInspection.ex.LocalInspectionToolWrapper) PsiElement(com.intellij.psi.PsiElement)

Example 4 with JavaDocReferenceInspection

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

the class LightAdvHighlightingJdk9Test method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    enableInspectionTools(new UnusedDeclarationInspection(), new UncheckedWarningLocalInspection(), new RedundantCastInspection(), new JavaDocReferenceInspection());
    setLanguageLevel(LanguageLevel.JDK_1_9);
    IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_9, getModule(), getTestRootDisposable());
}
Also used : JavaDocReferenceInspection(com.intellij.codeInspection.javaDoc.JavaDocReferenceInspection) RedundantCastInspection(com.intellij.codeInspection.redundantCast.RedundantCastInspection) UncheckedWarningLocalInspection(com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection) UnusedDeclarationInspection(com.intellij.codeInspection.deadCode.UnusedDeclarationInspection)

Example 5 with JavaDocReferenceInspection

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

the class SuppressModuleInfoInspectionsTest method testModuleInfo.

public void testModuleInfo() {
    // need to set jdk version here because it is not set correctly in the mock jdk which causes problems in
    // com.intellij.codeInspection.JavaSuppressionUtil#canHave15Suppressions()
    IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_9, myFixture.getModule(), getTestRootDisposable());
    final LocalInspectionTool inspection = new JavaDocReferenceInspection();
    myFixture.enableInspections(inspection);
    myFixture.configureByFile("module-info.java");
    myFixture.testHighlighting();
    myFixture.launchAction(myFixture.findSingleIntention("Suppress for module declaration"));
    myFixture.checkResultByFile("module-info.after.java");
}
Also used : JavaDocReferenceInspection(com.intellij.codeInspection.javaDoc.JavaDocReferenceInspection) LocalInspectionTool(com.intellij.codeInspection.LocalInspectionTool)

Aggregations

JavaDocReferenceInspection (com.intellij.codeInspection.javaDoc.JavaDocReferenceInspection)5 UnusedDeclarationInspection (com.intellij.codeInspection.deadCode.UnusedDeclarationInspection)2 JavaDocLocalInspection (com.intellij.codeInspection.javaDoc.JavaDocLocalInspection)2 InspectionManager (com.intellij.codeInspection.InspectionManager)1 LocalInspectionTool (com.intellij.codeInspection.LocalInspectionTool)1 ProblemDescriptor (com.intellij.codeInspection.ProblemDescriptor)1 EmptyMethodInspection (com.intellij.codeInspection.emptyMethod.EmptyMethodInspection)1 GlobalInspectionToolWrapper (com.intellij.codeInspection.ex.GlobalInspectionToolWrapper)1 InspectionToolWrapper (com.intellij.codeInspection.ex.InspectionToolWrapper)1 LocalInspectionToolWrapper (com.intellij.codeInspection.ex.LocalInspectionToolWrapper)1 I18nInspection (com.intellij.codeInspection.i18n.I18nInspection)1 RedundantCastInspection (com.intellij.codeInspection.redundantCast.RedundantCastInspection)1 UncheckedWarningLocalInspection (com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection)1 PsiElement (com.intellij.psi.PsiElement)1 PsiDocComment (com.intellij.psi.javadoc.PsiDocComment)1 RawUseOfParameterizedTypeInspection (com.siyeh.ig.migration.RawUseOfParameterizedTypeInspection)1 NotNull (org.jetbrains.annotations.NotNull)1