mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-176694 redundant attribute inspection ignores the fixed attribute in xml schema
This commit is contained in:
@@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<root xmlns="test.required" required="foo" fixed=<warning descr="Redundant default attribute value assignment">"foo"</warning>/>
|
||||
@@ -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>
|
||||
+1
-1
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user