use of com.intellij.xml.impl.schema.ComplexTypeDescriptor in project intellij-community by JetBrains.
the class XmlUtil method getSchemaSimpleContent.
@Nullable
public static XmlTag getSchemaSimpleContent(@NotNull XmlTag tag) {
XmlElementDescriptor descriptor = tag.getDescriptor();
if (descriptor instanceof XmlElementDescriptorImpl) {
final TypeDescriptor type = ((XmlElementDescriptorImpl) descriptor).getType(tag);
if (type instanceof ComplexTypeDescriptor) {
final XmlTag[] simpleContent = new XmlTag[1];
processXmlElements(((ComplexTypeDescriptor) type).getDeclaration(), new PsiElementProcessor() {
@Override
public boolean execute(@NotNull final PsiElement element) {
if (element instanceof XmlTag) {
final XmlTag tag = (XmlTag) element;
@NonNls final String s = ((XmlTag) element).getLocalName();
if ((s.equals(XSD_SIMPLE_CONTENT_TAG) || s.equals("restriction") && "string".equals(findLocalNameByQualifiedName(tag.getAttributeValue("base")))) && tag.getNamespace().equals(XML_SCHEMA_URI)) {
simpleContent[0] = tag;
return false;
}
}
return true;
}
}, true);
return simpleContent[0];
}
}
return null;
}
use of com.intellij.xml.impl.schema.ComplexTypeDescriptor in project intellij-community by JetBrains.
the class TypeOrElementOrAttributeReference method resolveInner.
private PsiElement resolveInner() {
final XmlTag tag = PsiTreeUtil.getContextOfType(myElement, XmlTag.class, false);
if (tag == null)
return PsiUtilCore.NULL_PSI_ELEMENT;
String canonicalText = getCanonicalText();
boolean[] redefined = new boolean[1];
XmlNSDescriptorImpl nsDescriptor = getDescriptor(tag, canonicalText, redefined);
if (myType != null && nsDescriptor != null && nsDescriptor.getTag() != null) {
switch(myType) {
case GroupReference:
return nsDescriptor.findGroup(canonicalText);
case AttributeGroupReference:
return nsDescriptor.findAttributeGroup(canonicalText);
case ElementReference:
{
XmlElementDescriptor descriptor = nsDescriptor.getElementDescriptor(XmlUtil.findLocalNameByQualifiedName(canonicalText), getNamespace(tag, canonicalText), new HashSet<>(), true);
return descriptor != null ? descriptor.getDeclaration() : PsiUtilCore.NULL_PSI_ELEMENT;
}
case AttributeReference:
{
//final String prefixByQualifiedName = XmlUtil.findPrefixByQualifiedName(canonicalText);
final String localNameByQualifiedName = XmlUtil.findLocalNameByQualifiedName(canonicalText);
XmlAttributeDescriptor descriptor = nsDescriptor.getAttribute(localNameByQualifiedName, getNamespace(tag, canonicalText), tag);
if (descriptor != null)
return descriptor.getDeclaration();
return PsiUtilCore.NULL_PSI_ELEMENT;
}
case TypeReference:
{
TypeDescriptor typeDescriptor = redefined[0] ? nsDescriptor.findTypeDescriptor(XmlUtil.findLocalNameByQualifiedName(canonicalText), "") : nsDescriptor.getTypeDescriptor(canonicalText, tag);
if (typeDescriptor instanceof ComplexTypeDescriptor) {
return typeDescriptor.getDeclaration();
} else if (typeDescriptor != null) {
return myElement;
}
}
}
}
return PsiUtilCore.NULL_PSI_ELEMENT;
}
Aggregations