diff --git a/xml/xml-psi-impl/src/com/intellij/javaee/InternalResourceProvider.java b/xml/xml-psi-impl/src/com/intellij/javaee/InternalResourceProvider.java index 92595b69a71b..bb471194e659 100644 --- a/xml/xml-psi-impl/src/com/intellij/javaee/InternalResourceProvider.java +++ b/xml/xml-psi-impl/src/com/intellij/javaee/InternalResourceProvider.java @@ -1,4 +1,4 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.javaee; import com.intellij.xml.util.XmlUtil; @@ -11,41 +11,44 @@ public final class InternalResourceProvider implements StandardResourceProvider public void registerResources(ResourceRegistrar registrar) { ResourceRegistrarImpl impl = (ResourceRegistrarImpl)registrar; - impl.addInternalResource(XmlUtil.XSLT_URI, "xslt-1_0.xsd"); - impl.addInternalResource(XmlUtil.XSLT_URI, "2.0", "xslt-2_0.xsd"); - impl.addInternalResource(XmlUtil.XINCLUDE_URI, "xinclude.xsd"); + ClassLoader classLoader = InternalResourceProvider.class.getClassLoader(); - impl.addInternalResource(XmlUtil.XML_SCHEMA_URI, "XMLSchema.xsd"); - impl.addInternalResource(XmlUtil.XML_SCHEMA_URI + ".xsd", "XMLSchema.xsd"); + impl.addInternalResource(XmlUtil.XSLT_URI, "xslt-1_0.xsd", classLoader); + impl.addInternalResource(XmlUtil.XSLT_URI, "2.0", "xslt-2_0.xsd", classLoader); + impl.addInternalResource(XmlUtil.XINCLUDE_URI, "xinclude.xsd", classLoader); - impl.addInternalResource("http://www.w3.org/2001/XMLSchema.dtd", "XMLSchema.dtd"); - impl.addInternalResource(XmlUtil.XML_SCHEMA_INSTANCE_URI, "XMLSchema-instance.xsd"); - impl.addInternalResource(XmlUtil.XML_SCHEMA_VERSIONING_URI, "XMLSchema-versioning.xsd"); - impl.addInternalResource("http://www.w3.org/2001/xml.xsd", "xml.xsd"); - impl.addInternalResource(XmlUtil.XML_NAMESPACE_URI, "xml.xsd"); - impl.addInternalResource(XmlUtil.XHTML_URI, "xhtml1-transitional.xsd"); - impl.addInternalResource("http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd", "xhtml1-strict.xsd"); + impl.addInternalResource(XmlUtil.XML_SCHEMA_URI, "XMLSchema.xsd", classLoader); + impl.addInternalResource(XmlUtil.XML_SCHEMA_URI + ".xsd", "XMLSchema.xsd", classLoader); - impl.addInternalResource("http://www.w3.org/TR/html4/strict.dtd", "xhtml1-strict.dtd"); - impl.addInternalResource(XmlUtil.HTML4_LOOSE_URI, "xhtml1-transitional.dtd"); - impl.addInternalResource("http://www.w3.org/TR/html4/frameset.dtd", "xhtml1-frameset.dtd"); - impl.addInternalResource("http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd", "xhtml1-strict.dtd"); - impl.addInternalResource("http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd", "xhtml1-transitional.dtd"); - impl.addInternalResource("http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd", "xhtml1-frameset.dtd"); - impl.addInternalResource("http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd", "xhtml11/xhtml11.dtd"); + impl.addInternalResource("http://www.w3.org/2001/XMLSchema.dtd", "XMLSchema.dtd", classLoader); + impl.addInternalResource(XmlUtil.XML_SCHEMA_INSTANCE_URI, "XMLSchema-instance.xsd", classLoader); + impl.addInternalResource(XmlUtil.XML_SCHEMA_VERSIONING_URI, "XMLSchema-versioning.xsd", classLoader); + impl.addInternalResource("http://www.w3.org/2001/xml.xsd", "xml.xsd", classLoader); + impl.addInternalResource(XmlUtil.XML_NAMESPACE_URI, "xml.xsd", classLoader); + impl.addInternalResource(XmlUtil.XHTML_URI, "xhtml1-transitional.xsd", classLoader); + impl.addInternalResource("http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd", "xhtml1-strict.xsd", classLoader); - impl.addInternalResource("urn:oasis:names:tc:entity:xmlns:xml:catalog", "catalog.xsd"); + impl.addInternalResource("http://www.w3.org/TR/html4/strict.dtd", "xhtml1-strict.dtd", classLoader); + impl.addInternalResource(XmlUtil.HTML4_LOOSE_URI, "xhtml1-transitional.dtd", classLoader); + impl.addInternalResource("http://www.w3.org/TR/html4/frameset.dtd", "xhtml1-frameset.dtd", classLoader); + impl.addInternalResource("http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd", "xhtml1-strict.dtd", classLoader); + impl.addInternalResource("http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd", "xhtml1-transitional.dtd", classLoader); + impl.addInternalResource("http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd", "xhtml1-frameset.dtd", classLoader); + impl.addInternalResource("http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd", "xhtml11/xhtml11.dtd", classLoader); + + impl.addInternalResource("urn:oasis:names:tc:entity:xmlns:xml:catalog", "catalog.xsd", classLoader); // Enterprise Plugin Repository - impl.addInternalResource("http://plugins.intellij.net/plugin-repository.dtd", "plugin-repository.dtd"); + impl.addInternalResource("http://plugins.intellij.net/plugin-repository.dtd", "plugin-repository.dtd", classLoader); // mobile - impl.addInternalResource("http://www.wapforum.org/DTD/xhtml-mobile10.dtd", "xhtml-mobile/xhtml-mobile10.dtd"); - impl.addInternalResource("http://www.wapforum.org/DTD/xhtml-mobile10-flat.dtd", "xhtml-mobile/xhtml-mobile10-flat.dtd"); - impl.addInternalResource("http://www.wapforum.org/DTD/xhtml-mobile12.dtd", "xhtml-mobile/xhtml-mobile12.dtd"); + impl.addInternalResource("http://www.wapforum.org/DTD/xhtml-mobile10.dtd", "xhtml-mobile/xhtml-mobile10.dtd", classLoader); + impl.addInternalResource("http://www.wapforum.org/DTD/xhtml-mobile10-flat.dtd", "xhtml-mobile/xhtml-mobile10-flat.dtd", classLoader); + impl.addInternalResource("http://www.wapforum.org/DTD/xhtml-mobile12.dtd", "xhtml-mobile/xhtml-mobile12.dtd", classLoader); - impl.addInternalResource("http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd", "xhtml-mobile/xhtml-mobile12.dtd"); + impl.addInternalResource("http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd", "xhtml-mobile/xhtml-mobile12.dtd", + classLoader); - impl.addInternalResource("http://www.w3.org/1999/xlink", "xlink.dtd"); + impl.addInternalResource("http://www.w3.org/1999/xlink", "xlink.dtd", classLoader); } } diff --git a/xml/xml-psi-impl/src/com/intellij/javaee/ResourceRegistrarImpl.kt b/xml/xml-psi-impl/src/com/intellij/javaee/ResourceRegistrarImpl.kt index 86f6a2cea5ac..0b1e69ee3cfb 100644 --- a/xml/xml-psi-impl/src/com/intellij/javaee/ResourceRegistrarImpl.kt +++ b/xml/xml-psi-impl/src/com/intellij/javaee/ResourceRegistrarImpl.kt @@ -26,7 +26,7 @@ class ResourceRegistrarImpl : ResourceRegistrar { aClass: Class<*>?, classLoader: ClassLoader? ) { - ExternalResourceManagerExImpl.getOrCreateMap(resources, version) + ExternalResourceManagerExImpl.getOrCreateMap(resources, version) .put(resource, ExternalResourceManagerExImpl.Resource(file = fileName, aClass = aClass, classLoader = classLoader)) } @@ -38,22 +38,28 @@ class ResourceRegistrarImpl : ResourceRegistrar { ignored.add(url) } + @Deprecated("Pass class loader explicitly", level = DeprecationLevel.ERROR) fun addInternalResource(resource: @NonNls String, fileName: @NonNls String?) { - addInternalResource(resource = resource, version = null, fileName = fileName, aClass = javaClass) + addStdResource( + resource = resource, + version = null, + fileName = ExternalResourceManagerEx.STANDARD_SCHEMAS.trimStart('/') + fileName, + aClass = null, + classLoader = javaClass.classLoader, + ) } - fun addInternalResource(resource: @NonNls String, fileName: @NonNls String?, aClass: Class<*>?) { - addInternalResource(resource = resource, version = null, fileName = fileName, aClass = aClass) + fun addInternalResource(resource: @NonNls String, fileName: @NonNls String?, classLoader: ClassLoader) { + addInternalResource(resource = resource, version = null, fileName = fileName, classLoader = classLoader) } - @JvmOverloads - fun addInternalResource(resource: @NonNls String, version: @NonNls String?, fileName: @NonNls String?, aClass: Class<*>? = javaClass) { + fun addInternalResource(resource: @NonNls String, version: @NonNls String?, fileName: @NonNls String?, classLoader: ClassLoader) { addStdResource( resource = resource, version = version, - fileName = ExternalResourceManagerEx.STANDARD_SCHEMAS + fileName, - aClass = aClass, - classLoader = null, + fileName = ExternalResourceManagerEx.STANDARD_SCHEMAS.trimStart('/') + fileName, + aClass = null, + classLoader = classLoader, ) }