use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlElementDescriptorByType method getNSDescriptor.
@Override
public XmlNSDescriptor getNSDescriptor() {
XmlNSDescriptor nsDescriptor = NSDescriptor;
if (nsDescriptor == null) {
final XmlFile file = XmlUtil.getContainingFile(getType(null).getDeclaration());
if (file == null)
return null;
final XmlDocument document = file.getDocument();
if (document == null)
return null;
NSDescriptor = nsDescriptor = (XmlNSDescriptor) document.getMetaData();
}
return nsDescriptor;
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlNSDescriptorImpl method getNSDescriptorToSearchIn.
@NotNull
static XmlNSDescriptorImpl getNSDescriptorToSearchIn(XmlTag rootTag, final String name, XmlNSDescriptorImpl defaultNSDescriptor) {
if (name == null)
return defaultNSDescriptor;
final String namespacePrefix = XmlUtil.findPrefixByQualifiedName(name);
if (namespacePrefix.length() > 0) {
final String namespace = rootTag.getNamespaceByPrefix(namespacePrefix);
final XmlNSDescriptor nsDescriptor = rootTag.getNSDescriptor(namespace, true);
if (nsDescriptor instanceof XmlNSDescriptorImpl) {
return (XmlNSDescriptorImpl) nsDescriptor;
}
}
return defaultNSDescriptor;
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlNSDescriptorImpl method findNSDescriptor.
private XmlNSDescriptorImpl findNSDescriptor(final XmlTag tag, final XmlDocument document) {
final XmlNSDescriptorImpl nsDescriptor;
if (IMPORT_TAG_NAME.equals(tag.getLocalName())) {
final XmlNSDescriptor importedDescriptor = (XmlNSDescriptor) document.getMetaData();
nsDescriptor = (importedDescriptor instanceof XmlNSDescriptorImpl) ? (XmlNSDescriptorImpl) importedDescriptor : this;
} else {
nsDescriptor = this;
}
return nsDescriptor;
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlMover method moveTags.
private static boolean moveTags(MoveInfo info, XmlTag moved, XmlTag target, boolean down) {
if (target.getParent() == moved) {
// we are going to jump into our own children
// this can mean that target computed incorrectly
XmlTag next = down ? PsiTreeUtil.getNextSiblingOfType(moved, XmlTag.class) : PsiTreeUtil.getPrevSiblingOfType(moved, XmlTag.class);
if (next == null)
return info.prohibitMove();
info.toMove = new LineRange(moved);
info.toMove2 = new LineRange(next);
return true;
} else if (moved.getParent() == target) {
return false;
}
LineRange targetRange = new LineRange(target);
targetRange = XmlChildRole.CLOSING_TAG_START_FINDER.findChild(target.getNode()) == null ? new LineRange(targetRange.startLine, targetRange.endLine - 1) : targetRange;
if (targetRange.contains(info.toMove2)) {
// we are going to jump into sibling tag
XmlElementDescriptor descriptor = moved.getDescriptor();
if (descriptor == null)
return false;
XmlNSDescriptor nsDescriptor = descriptor.getNSDescriptor();
if (nsDescriptor == null)
return false;
XmlFile descriptorFile = nsDescriptor.getDescriptorFile();
if (descriptorFile == null || XmlDocumentImpl.isAutoGeneratedSchema(descriptorFile))
return false;
if (!TagNameVariantCollector.couldContain(target, moved)) {
info.toMove = new LineRange(moved);
info.toMove2 = targetRange;
return true;
}
}
return false;
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class HtmlElementDescriptorImpl method getAttributeDescriptor.
@Override
public XmlAttributeDescriptor getAttributeDescriptor(String attributeName, final XmlTag context) {
String caseSensitiveAttributeName = !myCaseSensitive ? attributeName.toLowerCase() : attributeName;
XmlAttributeDescriptor descriptor = super.getAttributeDescriptor(caseSensitiveAttributeName, context);
if (descriptor == null)
descriptor = RelaxedHtmlFromSchemaElementDescriptor.getAttributeDescriptorFromFacelets(attributeName, context);
if (descriptor == null) {
String prefix = XmlUtil.findPrefixByQualifiedName(attributeName);
if ("xml".equals(prefix)) {
// todo this is not technically correct dtd document references namespaces but we should handle it at least for xml stuff
XmlNSDescriptor nsdescriptor = context.getNSDescriptor(XmlUtil.XML_NAMESPACE_URI, true);
if (nsdescriptor instanceof XmlNSDescriptorImpl) {
descriptor = ((XmlNSDescriptorImpl) nsdescriptor).getAttribute(XmlUtil.findLocalNameByQualifiedName(caseSensitiveAttributeName), XmlUtil.XML_NAMESPACE_URI, context);
}
}
}
if (descriptor == null && HtmlUtil.isHtml5Context(context)) {
descriptor = myDelegate.getAttributeDescriptor(attributeName, context);
}
return descriptor;
}
Aggregations