Search in sources :

Example 1 with CreateHtmlDescriptionFix

use of org.jetbrains.idea.devkit.inspections.quickfix.CreateHtmlDescriptionFix in project intellij-community by JetBrains.

the class InspectionDescriptionNotFoundInspection method checkClass.

@Override
public ProblemDescriptor[] checkClass(@NotNull PsiClass psiClass, @NotNull InspectionManager manager, boolean isOnTheFly) {
    final Project project = psiClass.getProject();
    final PsiIdentifier nameIdentifier = psiClass.getNameIdentifier();
    final Module module = ModuleUtilCore.findModuleForPsiElement(psiClass);
    if (nameIdentifier == null || module == null || !PsiUtil.isInstantiable(psiClass))
        return null;
    final PsiClass base = JavaPsiFacade.getInstance(project).findClass(INSPECTION_PROFILE_ENTRY, psiClass.getResolveScope());
    if (base == null || !psiClass.isInheritor(base, true) || isPathMethodsAreOverridden(psiClass))
        return null;
    final InspectionDescriptionInfo info = InspectionDescriptionInfo.create(module, psiClass);
    if (!info.isValid() || info.hasDescriptionFile())
        return null;
    final PsiElement problemElement = getProblemElement(psiClass, info.getShortNameMethod());
    final ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(problemElement == null ? nameIdentifier : problemElement, "Inspection does not have a description", isOnTheFly, new LocalQuickFix[] { new CreateHtmlDescriptionFix(info.getFilename(), module, DescriptionType.INSPECTION) }, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
    return new ProblemDescriptor[] { problemDescriptor };
}
Also used : Project(com.intellij.openapi.project.Project) CreateHtmlDescriptionFix(org.jetbrains.idea.devkit.inspections.quickfix.CreateHtmlDescriptionFix) ProblemDescriptor(com.intellij.codeInspection.ProblemDescriptor) Module(com.intellij.openapi.module.Module)

Aggregations

ProblemDescriptor (com.intellij.codeInspection.ProblemDescriptor)1 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 CreateHtmlDescriptionFix (org.jetbrains.idea.devkit.inspections.quickfix.CreateHtmlDescriptionFix)1