Search in sources :

Example 1 with ExternalResourceManager

use of com.intellij.javaee.ExternalResourceManager in project intellij-community by JetBrains.

the class RngXmlValidationTest method init.

@Override
protected void init() {
    super.init();
    ApplicationManager.getApplication().runWriteAction(() -> {
        final ExternalResourceManager mgr = ExternalResourceManager.getInstance();
        mgr.addResource("urn:test:simple.rng", toAbsolutePath("validation/simple.rng"));
        mgr.addResource("urn:test:simple.rnc", toAbsolutePath("validation/simple.rnc"));
    //mgr.addResource("http://www.w3.org/1999/XSL/Transform", toAbsolutePath("validation/relaxng.rng"));
    });
}
Also used : ExternalResourceManager(com.intellij.javaee.ExternalResourceManager)

Example 2 with ExternalResourceManager

use of com.intellij.javaee.ExternalResourceManager 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);
                }
            }
        }
    }
}
Also used : ExternalResourceManager(com.intellij.javaee.ExternalResourceManager) PsiMetaData(com.intellij.psi.meta.PsiMetaData) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) XmlNSDescriptorImpl(com.intellij.xml.impl.schema.XmlNSDescriptorImpl)

Example 3 with ExternalResourceManager

use of com.intellij.javaee.ExternalResourceManager in project intellij-community by JetBrains.

the class XmlCompletionTest method addResource.

private void addResource(final String url, final String location) {
    final ExternalResourceManager manager = ExternalResourceManager.getInstance();
    final String old = manager.getResourceLocation(url, (String) null);
    if (old != null && //strange hack: ERM returns url as location sometimes
    old != url) {
        return;
    }
    ExternalResourceManagerExImpl.addTestResource(url, location, myFixture.getTestRootDisposable());
}
Also used : ExternalResourceManager(com.intellij.javaee.ExternalResourceManager)

Aggregations

ExternalResourceManager (com.intellij.javaee.ExternalResourceManager)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 PsiMetaData (com.intellij.psi.meta.PsiMetaData)1 XmlNSDescriptorImpl (com.intellij.xml.impl.schema.XmlNSDescriptorImpl)1