IDEA-176694 redundant attribute inspection ignores the fixed attribute in xml schema

This commit is contained in:
Dmitry Avdeev
2017-09-04 20:51:08 +03:00
parent 919bff24d5
commit dbe6ff737f
4 changed files with 23 additions and 1 deletions
@@ -19,8 +19,11 @@ import com.intellij.codeInsight.daemon.impl.analysis.XmlDefaultAttributeValueIns
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.ide.highlighter.HtmlFileType;
import com.intellij.ide.highlighter.XmlFileType;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase;
import java.io.File;
/**
* @author Dmitry Avdeev
*/
@@ -63,4 +66,14 @@ public class XmlInspectionsTest extends LightPlatformCodeInsightFixtureTestCase
myFixture.configureByText(HtmlFileType.INSTANCE, "<input type=\"text\"/>");
myFixture.checkHighlighting();
}
public void testRequiredFixedAttribute() {
myFixture.enableInspections(new XmlDefaultAttributeValueInspection());
myFixture.testHighlighting("def.xml", "def.xsd");
}
@Override
protected String getTestDataPath() {
return PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/') + "/xml/tests/testData/xml";
}
}
+1
View File
@@ -0,0 +1 @@
<root xmlns="test.required" required="foo" fixed=<warning descr="Redundant default attribute value assignment">"foo"</warning>/>
+8
View File
@@ -0,0 +1,8 @@
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="test.required">
<element name="root">
<complexType>
<attribute name="required" fixed="foo" use="required"/>
<attribute name="fixed" fixed="foo"/>
</complexType>
</element>
</schema>
@@ -46,7 +46,7 @@ public class XmlDefaultAttributeValueInspection extends XmlSuppressableInspectio
}
if (parent.getParent() instanceof HtmlTag) return;
XmlAttributeDescriptor descriptor = ((XmlAttribute)parent).getDescriptor();
if (descriptor == null) {
if (descriptor == null || descriptor.isRequired()) {
return;
}
String defaultValue = descriptor.getDefaultValue();