diff --git a/xml/tests/src/com/intellij/codeInsight/completion/XmlCompletionTest.java b/xml/tests/src/com/intellij/codeInsight/completion/XmlCompletionTest.java
index 574942bc1207..e86012369ebb 100644
--- a/xml/tests/src/com/intellij/codeInsight/completion/XmlCompletionTest.java
+++ b/xml/tests/src/com/intellij/codeInsight/completion/XmlCompletionTest.java
@@ -646,5 +646,23 @@ public class XmlCompletionTest extends LightCodeInsightFixtureTestCase {
assertEquals("src", strings.get(1));
assertEquals("align", strings.get(2));
}
+
+ public void testDoNotProcessAnyInRestrictions() throws Exception {
+ myFixture.configureByText("foo.xsd", "\n" +
+ " <\n" +
+ "");
+ myFixture.completeBasic();
+ assertSameElements(myFixture.getLookupElementStrings(), "xs:annotation",
+ "xs:attribute",
+ "xs:attributeGroup",
+ "xs:complexType",
+ "xs:element",
+ "xs:group",
+ "xs:import",
+ "xs:include",
+ "xs:notation",
+ "xs:redefine",
+ "xs:simpleType");
+ }
}
diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/ComplexTypeDescriptor.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/ComplexTypeDescriptor.java
index 6068f42006bd..a6a2b1a540ed 100644
--- a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/ComplexTypeDescriptor.java
+++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/ComplexTypeDescriptor.java
@@ -269,7 +269,7 @@ public class ComplexTypeDescriptor extends TypeDescriptor {
public boolean canContainTag(String localName, String namespace, XmlElement context) {
return _canContainTag(localName, namespace, myTag, context, new HashSet(5),
- new CurrentContextInfo(myDocumentDescriptor, myDocumentDescriptor.getDefaultNamespace()));
+ new CurrentContextInfo(myDocumentDescriptor, myDocumentDescriptor.getDefaultNamespace()), false);
}
static class CurrentContextInfo {
@@ -298,12 +298,14 @@ public class ComplexTypeDescriptor extends TypeDescriptor {
}
private boolean _canContainTag(String localName, String namespace, XmlTag tag, XmlElement context, Set visited,
- CurrentContextInfo info) {
+ CurrentContextInfo info, boolean restriction) {
if (visited.contains(tag)) return false;
visited.add(tag);
if (XmlNSDescriptorImpl.equalsToSchemaName(tag, "any")) {
- myHasAnyInContentModel = true;
+ if (!restriction) {
+ myHasAnyInContentModel = true;
+ }
if (OTHER_NAMESPACE_ATTR_VALUE.equals(tag.getAttributeValue("namespace"))) {
return namespace == null || !namespace.equals(info.expectedDefaultNs);
}
@@ -315,7 +317,7 @@ public class ComplexTypeDescriptor extends TypeDescriptor {
if (ref != null) {
XmlTag groupTag = info.documentDescriptor.findGroup(ref);
if (groupTag != null) {
- if (_canContainTag(localName, namespace, groupTag, context, visited, getContextInfo(info, ref))) return true;
+ if (_canContainTag(localName, namespace, groupTag, context, visited, getContextInfo(info, ref), restriction)) return true;
}
}
}
@@ -329,7 +331,8 @@ public class ComplexTypeDescriptor extends TypeDescriptor {
if (descriptor instanceof ComplexTypeDescriptor) {
ComplexTypeDescriptor complexTypeDescriptor = (ComplexTypeDescriptor)descriptor;
if (complexTypeDescriptor._canContainTag(localName, namespace, complexTypeDescriptor.myTag, context, visited,
- getContextInfo(info, base))) {
+ getContextInfo(info, base), restriction || XmlNSDescriptorImpl.equalsToSchemaName(tag,
+ RESTRICTION_TAG_NAME))) {
myHasAnyInContentModel |= complexTypeDescriptor.myHasAnyInContentModel;
return true;
}
@@ -365,7 +368,7 @@ public class ComplexTypeDescriptor extends TypeDescriptor {
}
for (XmlTag subTag : tag.getSubTags()) {
- if (_canContainTag(localName, namespace, subTag, context, visited, info)) return true;
+ if (_canContainTag(localName, namespace, subTag, context, visited, info, restriction)) return true;
}
return false;