private void reportOneTagProblem( final XmlTag tag, final String name, final String localizedMessage, final IntentionAction basicIntention, final HighlightDisplayKey key, final XmlEntitiesInspection inspection, final int type) { boolean htmlTag = false; if (tag instanceof HtmlTag) { htmlTag = true; if (isAdditionallyDeclared(inspection.getAdditionalEntries(type), name)) return; } final InspectionProfile profile = InspectionProjectProfileManager.getInstance(tag.getProject()).getInspectionProfile(); final IntentionAction intentionAction = inspection.getIntentionAction(name, type); if (htmlTag && profile.isToolEnabled(key, tag)) { addElementsForTagWithManyQuickFixes( tag, localizedMessage, isInjectedHtmlTagForWhichNoProblemsReporting((HtmlTag) tag) ? HighlightInfoType.INFORMATION : SeverityRegistrar.getInstance(tag.getProject()) .getHighlightInfoTypeBySeverity(profile.getErrorLevel(key, tag).getSeverity()), intentionAction, basicIntention); } else if (!htmlTag) { addElementsForTag(tag, localizedMessage, HighlightInfoType.ERROR, basicIntention); } }
private void checkRequiredAttributes( XmlTag tag, String name, XmlElementDescriptor elementDescriptor) { XmlAttributeDescriptor[] attributeDescriptors = elementDescriptor.getAttributesDescriptors(tag); Set<String> requiredAttributes = null; for (XmlAttributeDescriptor attribute : attributeDescriptors) { if (attribute != null && attribute.isRequired()) { if (requiredAttributes == null) { requiredAttributes = new HashSet<String>(); } requiredAttributes.add(attribute.getName(tag)); } } if (requiredAttributes != null) { for (final String attrName : requiredAttributes) { if (tag.getAttribute(attrName, "") == null && !XmlExtension.getExtension(tag.getContainingFile()) .isRequiredAttributeImplicitlyPresent(tag, attrName)) { final InsertRequiredAttributeFix insertRequiredAttributeIntention = new InsertRequiredAttributeFix(tag, attrName, null); final String localizedMessage = XmlErrorMessages.message("element.doesnt.have.required.attribute", name, attrName); final InspectionProfile profile = InspectionProjectProfileManager.getInstance(tag.getProject()).getInspectionProfile(); final LocalInspectionToolWrapper toolWrapper = (LocalInspectionToolWrapper) profile.getInspectionTool(RequiredAttributesInspection.SHORT_NAME, tag); if (toolWrapper != null) { RequiredAttributesInspection inspection = (RequiredAttributesInspection) toolWrapper.getTool(); reportOneTagProblem( tag, attrName, localizedMessage, insertRequiredAttributeIntention, HighlightDisplayKey.find(RequiredAttributesInspection.SHORT_NAME), inspection, XmlEntitiesInspection.NOT_REQUIRED_ATTRIBUTE); } } } } }