use of com.intellij.xml.impl.schema.XmlNSDescriptorImpl in project intellij-community by JetBrains.
the class CreateNSDeclarationIntentionFix method processExternalUrisImpl.
private static void processExternalUrisImpl(final MetaHandler metaHandler, final PsiFile file, final ExternalUriProcessor processor) {
final ProgressIndicator pi = ProgressManager.getInstance().getProgressIndicator();
final String searchFor = metaHandler.searchFor();
if (pi != null)
pi.setText(XmlErrorMessages.message("looking.in.schemas"));
final ExternalResourceManager instanceEx = ExternalResourceManager.getInstance();
final String[] availableUrls = instanceEx.getResourceUrls(null, true);
int i = 0;
for (String url : availableUrls) {
if (pi != null) {
pi.setFraction((double) i / availableUrls.length);
pi.setText2(url);
++i;
}
final XmlFile xmlFile = XmlUtil.findNamespace(file, url);
if (xmlFile != null) {
final boolean wordFound = checkIfGivenXmlHasTheseWords(searchFor, xmlFile);
if (!wordFound)
continue;
final XmlDocument document = xmlFile.getDocument();
assert document != null;
final PsiMetaData metaData = document.getMetaData();
if (metaHandler.isAcceptableMetaData(metaData, url)) {
final XmlNSDescriptorImpl descriptor = metaData instanceof XmlNSDescriptorImpl ? (XmlNSDescriptorImpl) metaData : null;
final String defaultNamespace = descriptor != null ? descriptor.getDefaultNamespace() : url;
// Skip rare stuff
if (!XmlUtil.XML_SCHEMA_URI2.equals(defaultNamespace) && !XmlUtil.XML_SCHEMA_URI3.equals(defaultNamespace)) {
processor.process(defaultNamespace, url);
}
}
}
}
}
use of com.intellij.xml.impl.schema.XmlNSDescriptorImpl 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