Search in sources :

Example 1 with InspectionDescriptionInfo

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

the class DescriptionTypeRelatedItemLineMarkerProvider method process.

private static void process(PsiClass psiClass, Collection<? super RelatedItemLineMarkerInfo> result) {
    if (!PsiUtil.isInstantiable(psiClass))
        return;
    Module module = ModuleUtilCore.findModuleForPsiElement(psiClass);
    if (module == null)
        return;
    PsiElement highlightingElement = psiClass.getNameIdentifier();
    if (highlightingElement == null)
        return;
    for (DescriptionType type : DescriptionType.values()) {
        if (!InheritanceUtil.isInheritor(psiClass, type.getClassName())) {
            continue;
        }
        String descriptionDirName = DescriptionCheckerUtil.getDescriptionDirName(psiClass);
        if (StringUtil.isEmptyOrSpaces(descriptionDirName)) {
            return;
        }
        if (type == DescriptionType.INSPECTION) {
            final InspectionDescriptionInfo info = InspectionDescriptionInfo.create(module, psiClass);
            if (info.hasDescriptionFile()) {
                addDescriptionFileGutterIcon(highlightingElement, info.getDescriptionFile(), result);
            }
            return;
        }
        for (PsiDirectory descriptionDir : DescriptionCheckerUtil.getDescriptionsDirs(module, type)) {
            PsiDirectory dir = descriptionDir.findSubdirectory(descriptionDirName);
            if (dir == null)
                continue;
            final PsiFile descriptionFile = dir.findFile("description.html");
            if (descriptionFile != null) {
                addDescriptionFileGutterIcon(highlightingElement, descriptionFile, result);
                addBeforeAfterTemplateFilesGutterIcon(highlightingElement, dir, result);
                return;
            }
        }
        return;
    }
}
Also used : DescriptionType(org.jetbrains.idea.devkit.inspections.DescriptionType) PsiDirectory(com.intellij.psi.PsiDirectory) PsiFile(com.intellij.psi.PsiFile) Module(com.intellij.openapi.module.Module) PsiElement(com.intellij.psi.PsiElement) InspectionDescriptionInfo(org.jetbrains.idea.devkit.inspections.InspectionDescriptionInfo)

Aggregations

Module (com.intellij.openapi.module.Module)1 PsiDirectory (com.intellij.psi.PsiDirectory)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1 DescriptionType (org.jetbrains.idea.devkit.inspections.DescriptionType)1 InspectionDescriptionInfo (org.jetbrains.idea.devkit.inspections.InspectionDescriptionInfo)1