Search in sources :

Example 1 with ITNReporter

use of com.intellij.diagnostic.ITNReporter in project intellij-community by JetBrains.

the class PluginXmlDomInspection method annotateExtension.

private static void annotateExtension(Extension extension, DomElementAnnotationHolder holder) {
    final ExtensionPoint extensionPoint = extension.getExtensionPoint();
    if (extensionPoint == null)
        return;
    final GenericAttributeValue<PsiClass> interfaceAttribute = extensionPoint.getInterface();
    if (DomUtil.hasXml(interfaceAttribute)) {
        final PsiClass value = interfaceAttribute.getValue();
        if (value != null && value.isDeprecated()) {
            holder.createProblem(extension, ProblemHighlightType.LIKE_DEPRECATED, "Deprecated EP '" + extensionPoint.getEffectiveQualifiedName() + "'", null);
            return;
        }
    }
    if (ExtensionPoints.ERROR_HANDLER.equals(extensionPoint.getEffectiveQualifiedName()) && extension.exists()) {
        String implementation = extension.getXmlTag().getAttributeValue("implementation");
        if (ITNReporter.class.getName().equals(implementation)) {
            IdeaPlugin plugin = extension.getParentOfType(IdeaPlugin.class, true);
            if (plugin != null) {
                Vendor vendor = plugin.getVendor();
                if (DomUtil.hasXml(vendor) && PluginManagerMain.isDevelopedByJetBrains(vendor.getValue())) {
                    LocalQuickFix fix = new RemoveDomElementQuickFix(extension);
                    holder.createProblem(extension, ProblemHighlightType.LIKE_UNUSED_SYMBOL, "Exceptions from plugins developed by JetBrains are reported via ITNReporter automatically," + " there is no need to specify it explicitly", null, fix).highlightWholeElement();
                }
            }
        }
    }
    final List<? extends DomAttributeChildDescription> descriptions = extension.getGenericInfo().getAttributeChildrenDescriptions();
    for (DomAttributeChildDescription attributeDescription : descriptions) {
        final GenericAttributeValue attributeValue = attributeDescription.getDomAttributeValue(extension);
        if (attributeValue == null || !DomUtil.hasXml(attributeValue))
            continue;
        // IconsReferencesContributor
        if ("icon".equals(attributeDescription.getXmlElementName())) {
            annotateResolveProblems(holder, attributeValue);
        }
        final PsiElement declaration = attributeDescription.getDeclaration(extension.getManager().getProject());
        if (declaration instanceof PsiField) {
            PsiField psiField = (PsiField) declaration;
            if (psiField.isDeprecated()) {
                holder.createProblem(attributeValue, ProblemHighlightType.LIKE_DEPRECATED, "Deprecated attribute '" + attributeDescription.getName() + "'", null).highlightWholeElement();
            }
        }
    }
}
Also used : LocalQuickFix(com.intellij.codeInspection.LocalQuickFix) DomAttributeChildDescription(com.intellij.util.xml.reflect.DomAttributeChildDescription) ITNReporter(com.intellij.diagnostic.ITNReporter)

Aggregations

LocalQuickFix (com.intellij.codeInspection.LocalQuickFix)1 ITNReporter (com.intellij.diagnostic.ITNReporter)1 DomAttributeChildDescription (com.intellij.util.xml.reflect.DomAttributeChildDescription)1