diff --git a/plugins/devkit/testSources/codeInsight/PluginXmlFunctionalTest.groovy b/plugins/devkit/testSources/codeInsight/PluginXmlFunctionalTest.groovy index 506d792598c8..a1648cf722bd 100644 --- a/plugins/devkit/testSources/codeInsight/PluginXmlFunctionalTest.groovy +++ b/plugins/devkit/testSources/codeInsight/PluginXmlFunctionalTest.groovy @@ -18,6 +18,7 @@ import com.intellij.codeInsight.TargetElementUtilBase import com.intellij.codeInsight.completion.CompletionType import com.intellij.codeInspection.LocalInspectionTool import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection +import com.intellij.codeInspection.htmlInspections.RequiredAttributesInspection import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.PluginPathManager @@ -250,7 +251,8 @@ public class PluginXmlFunctionalTest extends JavaCodeInsightFixtureTestCase { ComponentNotRegisteredInspection.class, InspectionDescriptionNotFoundInspection.class, IntentionDescriptionNotFoundInspection.class, - InspectionMappingConsistencyInspection.class + InspectionMappingConsistencyInspection.class, + RequiredAttributesInspection.class ); } } diff --git a/xml/dom-impl/src/com/intellij/xml/impl/dom/DomAttributeXmlDescriptor.java b/xml/dom-impl/src/com/intellij/xml/impl/dom/DomAttributeXmlDescriptor.java index 0f43f5322977..635420098b6e 100644 --- a/xml/dom-impl/src/com/intellij/xml/impl/dom/DomAttributeXmlDescriptor.java +++ b/xml/dom-impl/src/com/intellij/xml/impl/dom/DomAttributeXmlDescriptor.java @@ -44,7 +44,8 @@ public class DomAttributeXmlDescriptor implements NamespaceAwareXmlAttributeDesc } public boolean isRequired() { - return myDescription.getAnnotation(Required.class) != null; + final Required required = myDescription.getAnnotation(Required.class); + return required != null && required.value(); } public boolean isFixed() { diff --git a/xml/dom-impl/src/com/intellij/xml/impl/dom/DomElementXmlDescriptor.java b/xml/dom-impl/src/com/intellij/xml/impl/dom/DomElementXmlDescriptor.java index 018de44b522d..d5894851bf93 100644 --- a/xml/dom-impl/src/com/intellij/xml/impl/dom/DomElementXmlDescriptor.java +++ b/xml/dom-impl/src/com/intellij/xml/impl/dom/DomElementXmlDescriptor.java @@ -15,6 +15,7 @@ */ package com.intellij.xml.impl.dom; +import com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightingAwareElementDescriptor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.text.StringUtil; @@ -36,7 +37,7 @@ import java.util.List; /** * @author mike */ -public class DomElementXmlDescriptor extends AbstractDomChildrenDescriptor { +public class DomElementXmlDescriptor extends AbstractDomChildrenDescriptor implements XmlHighlightingAwareElementDescriptor { private final DomChildrenDescription myChildrenDescription; public DomElementXmlDescriptor(@NotNull final DomElement domElement) { @@ -82,6 +83,11 @@ public class DomElementXmlDescriptor extends AbstractDomChildrenDescriptor { return name; } + @Override + public boolean shouldCheckRequiredAttributes() { + return false; + } + private static class MyRootDomChildrenDescription implements DomChildrenDescription { private final DomElement myDomElement; diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java index ed7102fd314b..d56b27def7ba 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java @@ -289,7 +289,10 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV } } - checkRequiredAttributes(tag, name, elementDescriptor); + if (!(elementDescriptor instanceof XmlHighlightingAwareElementDescriptor) || + ((XmlHighlightingAwareElementDescriptor)elementDescriptor).shouldCheckRequiredAttributes()) { + checkRequiredAttributes(tag, name, elementDescriptor); + } if (elementDescriptor instanceof Validator) { //noinspection unchecked diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightingAwareElementDescriptor.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightingAwareElementDescriptor.java new file mode 100644 index 000000000000..2ef2f498151c --- /dev/null +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightingAwareElementDescriptor.java @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.daemon.impl.analysis; + +/** + * @author Eugene.Kudelevsky + */ +public interface XmlHighlightingAwareElementDescriptor { + + boolean shouldCheckRequiredAttributes(); +}