check value of Required annotation; do not check required attributes of dom elements in XmlHighlightingVisitor; revive testing of required attribute validation in PluginXmlFunctionalTest

This commit is contained in:
Eugene Kudelevsky
2013-10-14 18:01:50 +04:00
parent 59d7274aa0
commit 050b38c495
5 changed files with 40 additions and 4 deletions
@@ -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
);
}
}
@@ -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() {
@@ -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;
@@ -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
@@ -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();
}