mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-185506: remove intellij.platform.indexing.impl dependency from xml psi impl
GitOrigin-RevId: 9f7c86f056f9c087299caaba3dbb54e0b1ef1960
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c1bd7d9629
commit
9507e7fdd8
@@ -140,6 +140,7 @@ jvm_library(
|
||||
"@lib//:maven-resolver-provider",
|
||||
"//java/java-syntax:syntax",
|
||||
"//platform/lang-impl",
|
||||
"//xml/impl",
|
||||
],
|
||||
runtime_deps = [
|
||||
":tests_test_resources",
|
||||
|
||||
@@ -115,5 +115,6 @@
|
||||
<orderEntry type="library" scope="TEST" name="maven-resolver-provider" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.java.syntax" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.platform.lang.impl" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.xml.impl" scope="TEST" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -92,8 +92,6 @@
|
||||
<with attribute="instance" implements="com.intellij.openapi.options.UnnamedConfigurable"/>
|
||||
</extensionPoint>
|
||||
|
||||
<extensionPoint name="xml.validateHandler" interface="com.intellij.xml.actions.validate.ValidateXmlHandler" dynamic="true"/>
|
||||
|
||||
<extensionPoint name="xml.namedReferenceProvider"
|
||||
dynamic="true"
|
||||
beanClass="com.intellij.xml.XmlNamedReferenceProviderBean">
|
||||
@@ -180,15 +178,12 @@
|
||||
|
||||
<standardResourceProvider implementation="com.intellij.javaee.InternalResourceProvider"/>
|
||||
|
||||
<projectService serviceInterface="com.intellij.javaee.ExternalResourceManagerExImpl"
|
||||
<projectService serviceInterface="com.intellij.javaee.ExternalResourceManagerExBase"
|
||||
serviceImplementation="com.intellij.javaee.ProjectResources"/>
|
||||
|
||||
<roots.watchedRootsProvider implementation="com.intellij.codeInsight.daemon.impl.quickfix.FetchExtResourceAction$MyWatchedRootsProvider"/>
|
||||
|
||||
<fileBasedIndex implementation="com.intellij.xml.index.XmlTagNamesIndex"/>
|
||||
<fileBasedIndex implementation="com.intellij.xml.index.XmlNamespaceIndex"/>
|
||||
<fileBasedIndex implementation="com.intellij.html.index.Html5CustomAttributesIndex"/>
|
||||
<fileBasedIndex implementation="com.intellij.xml.index.SchemaTypeInheritanceIndex"/>
|
||||
<include.provider implementation="com.intellij.xml.util.XIncludeProvider"/>
|
||||
<indexedRootsProvider implementation="com.intellij.javaee.ExternalResourcesRootsProvider"/>
|
||||
|
||||
@@ -492,19 +487,6 @@
|
||||
<defaultLiveTemplates file="liveTemplates/zen_xsl.xml"/>
|
||||
<productivityFeaturesProvider implementation="com.intellij.featureStatistics.XmlProductivityFeatureProvider"/>
|
||||
|
||||
<idIndexer filetype="XML" implementationClass="com.intellij.psi.impl.cache.impl.idCache.XmlIdIndexer"/>
|
||||
<idIndexer filetype="DTD" implementationClass="com.intellij.psi.impl.cache.impl.idCache.XmlIdIndexer"/>
|
||||
<idIndexer filetype="HTML" implementationClass="com.intellij.psi.impl.cache.impl.idCache.HtmlIdIndexer"/>
|
||||
<idIndexer filetype="XHTML" implementationClass="com.intellij.psi.impl.cache.impl.idCache.XHtmlIdIndexer"/>
|
||||
|
||||
<todoIndexer filetype="XML" implementationClass="com.intellij.psi.impl.cache.impl.idCache.XmlTodoIndexer"/>
|
||||
<todoIndexer filetype="DTD" implementationClass="com.intellij.psi.impl.cache.impl.idCache.XmlTodoIndexer"/>
|
||||
<todoIndexer filetype="HTML" implementationClass="com.intellij.psi.impl.cache.impl.idCache.HtmlTodoIndexer"/>
|
||||
<todoIndexer filetype="XHTML" implementationClass="com.intellij.psi.impl.cache.impl.idCache.XHtmlTodoIndexer"/>
|
||||
|
||||
<indexPatternBuilder implementation="com.intellij.psi.impl.cache.impl.idCache.HtmlIndexPatternBuilder" order="after xml"/>
|
||||
<indexPatternBuilder implementation="com.intellij.psi.impl.cache.impl.idCache.XmlIndexPatternBuilder" id="xml"/>
|
||||
|
||||
<elementSignatureProvider implementation="com.intellij.codeInsight.folding.impl.XmlElementSignatureProvider"/>
|
||||
|
||||
<vcsSelectionProvider implementation="com.intellij.vcsUtil.XmlVcsSelectionProvider"/>
|
||||
|
||||
@@ -43,6 +43,7 @@ jvm_library(
|
||||
"//platform/code-style-impl:codeStyle-impl",
|
||||
"//platform/platform-util-io-impl:ide-util-io-impl",
|
||||
"//platform/util/xmlDom",
|
||||
"//platform/util/jdom",
|
||||
"@lib//:aalto-xml",
|
||||
],
|
||||
exports = [
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<orderEntry type="module" module-name="intellij.platform.codeStyle.impl" />
|
||||
<orderEntry type="module" module-name="intellij.platform.ide.util.io.impl" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.xmlDom" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.jdom" />
|
||||
<orderEntry type="library" name="aalto-xml" level="project" />
|
||||
</component>
|
||||
<component name="copyright">
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright 2000-2025 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.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.VfsUtilCore
|
||||
import com.intellij.psi.util.CachedValueProvider
|
||||
import com.intellij.psi.util.CachedValuesManager
|
||||
import com.intellij.util.containers.MultiMap
|
||||
import com.intellij.xml.index.XmlNamespaceIndex
|
||||
|
||||
class ExternalResourceManagerExImpl: ExternalResourceManagerExBase() {
|
||||
private val urlByNamespaceProvider = CachedValueProvider {
|
||||
val result = MultiMap<String, String>()
|
||||
for (map in standardResources.value.values) {
|
||||
for (entry in map.entries) {
|
||||
val url = entry.value.getResourceUrl() ?: continue
|
||||
val file = VfsUtilCore.findRelativeFile(url, null) ?: continue
|
||||
val namespace = XmlNamespaceIndex.computeNamespace(file) ?: continue
|
||||
result.putValue(namespace, entry.key)
|
||||
}
|
||||
}
|
||||
CachedValueProvider.Result.create(result, this)
|
||||
}
|
||||
|
||||
override fun getUrlsByNamespace(project: Project): MultiMap<String, String>? {
|
||||
return CachedValuesManager.getManager(project).getCachedValue(project, urlByNamespaceProvider)
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.xml;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -23,6 +23,9 @@ jvm_library(
|
||||
"//platform/editor-ui-api:editor-ui",
|
||||
"//platform/editor-ui-ex:editor-ex",
|
||||
"//platform/lang-impl",
|
||||
"@lib//:xerces",
|
||||
"//platform/util/nanoxml",
|
||||
"//platform/indexing-impl",
|
||||
],
|
||||
exports = ["//xml/xml-analysis-api:analysis"],
|
||||
runtime_deps = [":analysis-impl_resources"]
|
||||
|
||||
@@ -18,5 +18,8 @@
|
||||
<orderEntry type="module" module-name="intellij.platform.editor.ui" />
|
||||
<orderEntry type="module" module-name="intellij.platform.editor.ex" />
|
||||
<orderEntry type="module" module-name="intellij.platform.lang.impl" />
|
||||
<orderEntry type="library" name="Xerces" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.nanoxml" />
|
||||
<orderEntry type="module" module-name="intellij.platform.indexing.impl" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -10,6 +10,8 @@
|
||||
<extensionPoint name="xml.undefinedElementFixProvider"
|
||||
interface="com.intellij.xml.XmlUndefinedElementFixProvider"
|
||||
dynamic="true"/>
|
||||
|
||||
<extensionPoint name="xml.validateHandler" interface="com.intellij.xml.actions.validate.ValidateXmlHandler" dynamic="true"/>
|
||||
</extensionPoints>
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<highlightingPassFactory order="last" implementation="com.intellij.xml.XmlCustomTagHighlightingPassFactory" />
|
||||
@@ -122,5 +124,27 @@
|
||||
<bundleName>messages.XmlBundle</bundleName>
|
||||
<className>com.intellij.codeInsight.daemon.impl.analysis.RemoveAttributeIntentionFix</className>
|
||||
</intentionAction>
|
||||
|
||||
<applicationService serviceImplementation="com.intellij.xml.index.XmlSchemaHelperImpl"
|
||||
serviceInterface="com.intellij.xml.impl.schema.XmlSchemaHelper"/>
|
||||
<applicationService serviceImplementation="com.intellij.xml.impl.ExternalDocumentValidatorHelperImpl"
|
||||
serviceInterface="com.intellij.xml.impl.ExternalDocumentValidatorHelper"/>
|
||||
|
||||
<idIndexer filetype="XML" implementationClass="com.intellij.psi.impl.cache.impl.idCache.XmlIdIndexer"/>
|
||||
<idIndexer filetype="DTD" implementationClass="com.intellij.psi.impl.cache.impl.idCache.XmlIdIndexer"/>
|
||||
<idIndexer filetype="HTML" implementationClass="com.intellij.psi.impl.cache.impl.idCache.HtmlIdIndexer"/>
|
||||
<idIndexer filetype="XHTML" implementationClass="com.intellij.psi.impl.cache.impl.idCache.XHtmlIdIndexer"/>
|
||||
|
||||
<todoIndexer filetype="XML" implementationClass="com.intellij.psi.impl.cache.impl.idCache.XmlTodoIndexer"/>
|
||||
<todoIndexer filetype="DTD" implementationClass="com.intellij.psi.impl.cache.impl.idCache.XmlTodoIndexer"/>
|
||||
<todoIndexer filetype="HTML" implementationClass="com.intellij.psi.impl.cache.impl.idCache.HtmlTodoIndexer"/>
|
||||
<todoIndexer filetype="XHTML" implementationClass="com.intellij.psi.impl.cache.impl.idCache.XHtmlTodoIndexer"/>
|
||||
|
||||
<indexPatternBuilder implementation="com.intellij.psi.impl.cache.impl.idCache.HtmlIndexPatternBuilder" order="after xml"/>
|
||||
<indexPatternBuilder implementation="com.intellij.psi.impl.cache.impl.idCache.XmlIndexPatternBuilder" id="xml"/>
|
||||
|
||||
<fileBasedIndex implementation="com.intellij.xml.index.XmlTagNamesIndex"/>
|
||||
<fileBasedIndex implementation="com.intellij.xml.index.XmlNamespaceIndex"/>
|
||||
<fileBasedIndex implementation="com.intellij.xml.index.SchemaTypeInheritanceIndex"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.xml.impl;
|
||||
|
||||
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.xml.impl;
|
||||
|
||||
import com.intellij.codeInsight.daemon.Validator;
|
||||
import com.intellij.psi.xml.XmlDocument;
|
||||
|
||||
public class ExternalDocumentValidatorHelperImpl implements ExternalDocumentValidatorHelper {
|
||||
@Override
|
||||
public void doValidation(XmlDocument document, Validator.ValidationHost host) {
|
||||
ExternalDocumentValidator.doValidation(document, host);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.xml.index;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.util.NullableFunction;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.xml.impl.schema.XmlSchemaHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class XmlSchemaHelperImpl implements XmlSchemaHelper {
|
||||
@Override
|
||||
public @Nullable XmlFile guessDtd(String dtdUri, @NotNull PsiFile baseFile) {
|
||||
return XmlNamespaceIndex.guessDtd(dtdUri, baseFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable XmlFile guessSchema(String namespace,
|
||||
@Nullable String tagName,
|
||||
@Nullable String version,
|
||||
@Nullable String schemaLocation,
|
||||
@NotNull PsiFile file) {
|
||||
return XmlNamespaceIndex.guessSchema(namespace, tagName, version, schemaLocation, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Unmodifiable @NotNull Collection<XmlFile> findNSFilesByURI(@NotNull String namespace,
|
||||
@NotNull Project project,
|
||||
@Nullable Module module) {
|
||||
final List<IndexedRelevantResource<String, XsdNamespaceBuilder>>
|
||||
resources = XmlNamespaceIndex.getResourcesByNamespace(namespace, project, module);
|
||||
final PsiManager psiManager = PsiManager.getInstance(project);
|
||||
return ContainerUtil.mapNotNull(resources,
|
||||
(NullableFunction<IndexedRelevantResource<String, XsdNamespaceBuilder>, XmlFile>)resource -> {
|
||||
PsiFile file = psiManager.findFile(resource.getFile());
|
||||
return file instanceof XmlFile ? (XmlFile)file : null;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -24,17 +24,13 @@ jvm_library(
|
||||
"//xml/xml-psi-api:psi",
|
||||
"//platform/core-api:core",
|
||||
"//platform/core-impl",
|
||||
"//platform/analysis-impl",
|
||||
"//xml/xml-parser:parser",
|
||||
"//platform/projectModel-impl",
|
||||
"//platform/indexing-impl",
|
||||
"@lib//:xerces",
|
||||
"//RegExpSupport:regexp",
|
||||
"//platform/ide-core-impl",
|
||||
"//platform/lang-api:lang",
|
||||
"//platform/lang-impl",
|
||||
"@lib//:xml-resolver",
|
||||
"//platform/util/nanoxml",
|
||||
"//platform/util:util-ui",
|
||||
"@lib//:fastutil-min",
|
||||
"@lib//:jackson",
|
||||
|
||||
@@ -16,17 +16,13 @@
|
||||
<orderEntry type="module" module-name="intellij.xml.psi" exported="" />
|
||||
<orderEntry type="module" module-name="intellij.platform.core" />
|
||||
<orderEntry type="module" module-name="intellij.platform.core.impl" />
|
||||
<orderEntry type="module" module-name="intellij.platform.analysis.impl" />
|
||||
<orderEntry type="module" module-name="intellij.xml.parser" />
|
||||
<orderEntry type="module" module-name="intellij.platform.projectModel.impl" />
|
||||
<orderEntry type="module" module-name="intellij.platform.indexing.impl" />
|
||||
<orderEntry type="library" name="Xerces" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.regexp" />
|
||||
<orderEntry type="module" module-name="intellij.platform.ide.core.impl" />
|
||||
<orderEntry type="module" module-name="intellij.platform.lang" />
|
||||
<orderEntry type="module" module-name="intellij.platform.lang.impl" />
|
||||
<orderEntry type="library" name="xml-resolver" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.nanoxml" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.ui" />
|
||||
<orderEntry type="library" name="fastutil-min" level="project" />
|
||||
<orderEntry type="library" name="jackson" level="project" />
|
||||
|
||||
+13
-28
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
@file:Suppress("ReplaceGetOrSet")
|
||||
|
||||
package com.intellij.javaee
|
||||
@@ -19,11 +19,8 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.util.SystemInfo
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.vfs.VfsUtilCore
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.util.CachedValueProvider
|
||||
import com.intellij.psi.util.CachedValuesManager
|
||||
import com.intellij.util.ArrayUtilRt
|
||||
import com.intellij.util.concurrency.SynchronizedClearableLazy
|
||||
import com.intellij.util.concurrency.ThreadingAssertions
|
||||
@@ -31,9 +28,9 @@ import com.intellij.util.containers.MultiMap
|
||||
import com.intellij.util.io.URLUtil
|
||||
import com.intellij.xml.Html5SchemaProvider
|
||||
import com.intellij.xml.XmlSchemaProvider
|
||||
import com.intellij.xml.index.XmlNamespaceIndex
|
||||
import com.intellij.xml.util.XmlUtil
|
||||
import org.jdom.Element
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import java.io.File
|
||||
@@ -43,13 +40,13 @@ import java.util.HashSet
|
||||
import java.util.LinkedList
|
||||
import java.util.TreeSet
|
||||
|
||||
private val LOG = logger<ExternalResourceManagerExImpl>()
|
||||
private val LOG = logger<ExternalResourceManagerExBase>()
|
||||
private const val DEFAULT_VERSION = ""
|
||||
|
||||
private const val CATALOG_PROPERTIES_ELEMENT = "CATALOG_PROPERTIES"
|
||||
private val XSD_1_1 = ExternalResource(
|
||||
file = "/standardSchemas/XMLSchema-1_1/XMLSchema.xsd",
|
||||
aClass = ExternalResourceManagerExImpl::class.java,
|
||||
aClass = ExternalResourceManagerExBase::class.java,
|
||||
classLoader = null,
|
||||
).getResourceUrl()
|
||||
|
||||
@@ -63,27 +60,14 @@ private const val HTML_DEFAULT_DOCTYPE_ELEMENT: @NonNls String = "default-html-d
|
||||
private const val XML_SCHEMA_VERSION: @NonNls String = "xml-schema-version"
|
||||
|
||||
@State(name = "ExternalResourceManagerImpl", storages = [Storage("javaeeExternalResources.xml")], category = SettingsCategory.CODE)
|
||||
open class ExternalResourceManagerExImpl : ExternalResourceManagerEx(), PersistentStateComponent<Element?> {
|
||||
open class ExternalResourceManagerExBase : ExternalResourceManagerEx(), PersistentStateComponent<Element?> {
|
||||
private val resources = HashMap<String, MutableMap<String, String>>()
|
||||
private val resourceLocations = HashSet<String>()
|
||||
|
||||
private val ignoredResources = Collections.synchronizedSet<String>(TreeSet<String>())
|
||||
private val standardIgnoredResources = Collections.synchronizedSet<String>(TreeSet<String>())
|
||||
private val ignoredResources = Collections.synchronizedSet(TreeSet<String>())
|
||||
private val standardIgnoredResources = Collections.synchronizedSet(TreeSet<String>())
|
||||
|
||||
private val standardResources = SynchronizedClearableLazy { computeStdResources() }
|
||||
|
||||
private val urlByNamespaceProvider = CachedValueProvider {
|
||||
val result = MultiMap<String, String>()
|
||||
for (map in standardResources.value.values) {
|
||||
for (entry in map.entries) {
|
||||
val url = entry.value.getResourceUrl() ?: continue
|
||||
val file = VfsUtilCore.findRelativeFile(url, null) ?: continue
|
||||
val namespace = XmlNamespaceIndex.computeNamespace(file) ?: continue
|
||||
result.putValue(namespace, entry.key)
|
||||
}
|
||||
}
|
||||
CachedValueProvider.Result.create(result, this)
|
||||
}
|
||||
protected val standardResources: SynchronizedClearableLazy<Map<String, MutableMap<String, ExternalResource>>> = SynchronizedClearableLazy { computeStdResources() }
|
||||
|
||||
private var defaultHtmlDoctype: String? = HTML5_DOCTYPE_ELEMENT
|
||||
private var xmlSchemaVersion = XMLSchemaVersion.XMLSchema_1_0
|
||||
@@ -489,7 +473,7 @@ open class ExternalResourceManagerExImpl : ExternalResourceManagerEx(), Persiste
|
||||
}
|
||||
|
||||
override fun getUrlsByNamespace(project: Project): MultiMap<String, String>? {
|
||||
return CachedValuesManager.getManager(project).getCachedValue(project, urlByNamespaceProvider)
|
||||
return MultiMap()
|
||||
}
|
||||
|
||||
private fun getCatalogManager(): XMLCatalogManager? {
|
||||
@@ -512,7 +496,8 @@ open class ExternalResourceManagerExImpl : ExternalResourceManagerEx(), Persiste
|
||||
}
|
||||
}
|
||||
|
||||
internal class ExternalResource(file: String, aClass: Class<*>?, classLoader: ClassLoader?) {
|
||||
@ApiStatus.Internal
|
||||
class ExternalResource(file: String, aClass: Class<*>?, classLoader: ClassLoader?) {
|
||||
private val file = file
|
||||
private val classLoader = classLoader
|
||||
private val aClass: Class<*>? = aClass
|
||||
@@ -566,7 +551,7 @@ internal class ExternalResource(file: String, aClass: Class<*>?, classLoader: Cl
|
||||
}
|
||||
|
||||
private fun <T> getMap(resources: Map<String, MutableMap<String, T>>, version: String?): MutableMap<String, T>? {
|
||||
var version = version ?: DEFAULT_VERSION
|
||||
val version = version ?: DEFAULT_VERSION
|
||||
val map = resources.get(version)
|
||||
return if (map == null && version != DEFAULT_VERSION) resources.get(DEFAULT_VERSION) else map
|
||||
}
|
||||
@@ -590,4 +575,4 @@ private fun isImplicitNamespaceDescriptor(url: String): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
private fun getProjectResources(project: Project): ExternalResourceManagerExImpl = project.service<ExternalResourceManagerExImpl>()
|
||||
private fun getProjectResources(project: Project): ExternalResourceManagerExBase = project.service<ExternalResourceManagerExBase>()
|
||||
@@ -11,7 +11,7 @@ import java.util.Map;
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
@State(name = "ProjectResources")
|
||||
final class ProjectResources extends ExternalResourceManagerExImpl {
|
||||
final class ProjectResources extends ExternalResourceManagerExBase {
|
||||
@Override
|
||||
public @NotNull Map<@NotNull String, @NotNull Map<@NotNull String, @NotNull ExternalResource>> computeStdResources$intellij_xml_psi_impl() {
|
||||
return Collections.emptyMap();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// 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 org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import java.util.ArrayList
|
||||
import java.util.HashMap
|
||||
@@ -9,7 +10,8 @@ class ResourceRegistrarImpl : ResourceRegistrar {
|
||||
private val resources = HashMap<String, MutableMap<String, ExternalResource>>()
|
||||
private val ignored = ArrayList<String>()
|
||||
|
||||
internal fun getIgnoredResources(): List<String> = ignored
|
||||
@ApiStatus.Internal
|
||||
fun getIgnoredResources(): List<String> = ignored
|
||||
|
||||
override fun addStdResource(resource: @NonNls String, fileName: @NonNls String, aClass: Class<*>?) {
|
||||
addStdResource(resource = resource, version = null, fileName = fileName, aClass = aClass)
|
||||
@@ -22,7 +24,7 @@ class ResourceRegistrarImpl : ResourceRegistrar {
|
||||
aClass: Class<*>?,
|
||||
classLoader: ClassLoader?
|
||||
) {
|
||||
ExternalResourceManagerExImpl.getOrCreateMap(resources, version)
|
||||
ExternalResourceManagerExBase.getOrCreateMap(resources, version)
|
||||
.put(resource, ExternalResource(file = fileName, aClass = aClass, classLoader = classLoader))
|
||||
}
|
||||
|
||||
@@ -54,12 +56,13 @@ class ResourceRegistrarImpl : ResourceRegistrar {
|
||||
}
|
||||
|
||||
fun addInternalResource(resource: @NonNls String, version: @NonNls String?, fileName: @NonNls String?, classLoader: ClassLoader) {
|
||||
ExternalResourceManagerExImpl.getOrCreateMap(resources, version = version).put(resource, ExternalResource(
|
||||
ExternalResourceManagerExBase.getOrCreateMap(resources, version = version).put(resource, ExternalResource(
|
||||
file = ExternalResourceManagerEx.STANDARD_SCHEMAS.trimStart('/') + fileName,
|
||||
aClass = null,
|
||||
classLoader = classLoader,
|
||||
))
|
||||
}
|
||||
|
||||
internal fun getResources(): Map<String, MutableMap<String, ExternalResource>> = resources
|
||||
@ApiStatus.Internal
|
||||
fun getResources(): Map<String, MutableMap<String, ExternalResource>> = resources
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import com.intellij.xml.XmlNSDescriptor;
|
||||
import com.intellij.xml.impl.schema.AnyXmlElementDescriptor;
|
||||
import com.intellij.xml.impl.schema.MultiFileNsDescriptor;
|
||||
import com.intellij.xml.impl.schema.XmlNSDescriptorImpl;
|
||||
import com.intellij.xml.index.XmlNamespaceIndex;
|
||||
import com.intellij.xml.impl.schema.XmlSchemaHelper;
|
||||
import com.intellij.xml.util.XmlPsiUtil;
|
||||
import com.intellij.xml.util.XmlTagUtil;
|
||||
import com.intellij.xml.util.XmlUtil;
|
||||
@@ -415,7 +415,7 @@ public abstract class XmlTagDelegate {
|
||||
return (XmlFile)psiFile;
|
||||
}
|
||||
|
||||
return XmlNamespaceIndex.guessSchema(namespace, nsDecl ? null : tag.getLocalName(), version, fileLocation, file);
|
||||
return XmlSchemaHelper.getInstance().guessSchema(namespace, nsDecl ? null : tag.getLocalName(), version, fileLocation, file);
|
||||
}
|
||||
|
||||
private static @Nullable PsiMetaOwner retrieveOwner(final @Nullable XmlTag tag,
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.xml.impl;
|
||||
|
||||
import com.intellij.codeInsight.daemon.Validator;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.psi.xml.XmlDocument;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public interface ExternalDocumentValidatorHelper {
|
||||
static ExternalDocumentValidatorHelper getInstance() {
|
||||
return ApplicationManager.getApplication().getService(ExternalDocumentValidatorHelper.class);
|
||||
}
|
||||
|
||||
void doValidation(final XmlDocument document, final Validator.ValidationHost host);
|
||||
}
|
||||
@@ -21,7 +21,7 @@ import com.intellij.util.AstLoadingFilter;
|
||||
import com.intellij.xml.Html5SchemaProvider;
|
||||
import com.intellij.xml.XmlExtension;
|
||||
import com.intellij.xml.XmlNSDescriptor;
|
||||
import com.intellij.xml.index.XmlNamespaceIndex;
|
||||
import com.intellij.xml.impl.schema.XmlSchemaHelper;
|
||||
import com.intellij.xml.util.XmlNSDescriptorSequence;
|
||||
import com.intellij.xml.util.XmlUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -174,7 +174,7 @@ public final class XmlNsDescriptorUtil {
|
||||
XmlFile xmlFile = XmlUtil.findNamespace(containingFile, dtdUri);
|
||||
if (xmlFile == null) {
|
||||
// try to auto-detect it
|
||||
xmlFile = XmlNamespaceIndex.guessDtd(dtdUri, containingFile);
|
||||
xmlFile = XmlSchemaHelper.getInstance().guessDtd(dtdUri, containingFile);
|
||||
}
|
||||
final String schemaFilePath = getFilePathForLogging(xmlFile);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import com.intellij.psi.util.CachedValuesManager;
|
||||
import com.intellij.psi.xml.*;
|
||||
import com.intellij.xml.XmlElementDescriptor;
|
||||
import com.intellij.xml.XmlNSDescriptorEx;
|
||||
import com.intellij.xml.impl.ExternalDocumentValidator;
|
||||
import com.intellij.xml.impl.ExternalDocumentValidatorHelper;
|
||||
import com.intellij.xml.util.XmlUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -190,7 +190,7 @@ public final class XmlNSDescriptorImpl implements XmlNSDescriptorEx,Validator<Xm
|
||||
);
|
||||
return;
|
||||
}
|
||||
ExternalDocumentValidator.doValidation(document,host);
|
||||
ExternalDocumentValidatorHelper.getInstance().doValidation(document, host);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,7 +28,7 @@ import com.intellij.xml.XmlAttributeDescriptor;
|
||||
import com.intellij.xml.XmlElementDescriptor;
|
||||
import com.intellij.xml.XmlNSDescriptor;
|
||||
import com.intellij.xml.XmlNSDescriptorEx;
|
||||
import com.intellij.xml.impl.ExternalDocumentValidator;
|
||||
import com.intellij.xml.impl.ExternalDocumentValidatorHelper;
|
||||
import com.intellij.xml.util.XmlUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -958,7 +958,7 @@ public class XmlNSDescriptorImpl implements XmlNSDescriptorEx,Validator<XmlDocum
|
||||
|
||||
@Override
|
||||
public void validate(@NotNull XmlDocument context, @NotNull Validator.ValidationHost host) {
|
||||
ExternalDocumentValidator.doValidation(context,host);
|
||||
ExternalDocumentValidatorHelper.getInstance().doValidation(context, host);
|
||||
}
|
||||
|
||||
public XmlTag getTag() {
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.xml.impl.schema;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public interface XmlSchemaHelper {
|
||||
static XmlSchemaHelper getInstance() {
|
||||
return ApplicationManager.getApplication().getService(XmlSchemaHelper.class);
|
||||
}
|
||||
|
||||
@Nullable XmlFile guessDtd(String dtdUri, @NotNull PsiFile baseFile);
|
||||
|
||||
@Nullable XmlFile guessSchema(String namespace,
|
||||
final @Nullable String tagName,
|
||||
final @Nullable String version,
|
||||
@Nullable String schemaLocation,
|
||||
@NotNull PsiFile file);
|
||||
|
||||
@Unmodifiable @NotNull Collection<XmlFile> findNSFilesByURI(@NotNull String namespace, @NotNull Project project, @Nullable Module module);
|
||||
}
|
||||
@@ -42,15 +42,11 @@ import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.xml.*;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.NullableFunction;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.text.XmlCharsetDetector;
|
||||
import com.intellij.xml.*;
|
||||
import com.intellij.xml.impl.schema.*;
|
||||
import com.intellij.xml.index.IndexedRelevantResource;
|
||||
import com.intellij.xml.index.XmlNamespaceIndex;
|
||||
import com.intellij.xml.index.XsdNamespaceBuilder;
|
||||
import com.intellij.xml.psi.XmlPsiBundle;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -213,14 +209,7 @@ public final class XmlUtil {
|
||||
}
|
||||
|
||||
public static @Unmodifiable @NotNull Collection<XmlFile> findNSFilesByURI(@NotNull String namespace, @NotNull Project project, @Nullable Module module) {
|
||||
final List<IndexedRelevantResource<String, XsdNamespaceBuilder>>
|
||||
resources = XmlNamespaceIndex.getResourcesByNamespace(namespace, project, module);
|
||||
final PsiManager psiManager = PsiManager.getInstance(project);
|
||||
return ContainerUtil.mapNotNull(resources,
|
||||
(NullableFunction<IndexedRelevantResource<String, XsdNamespaceBuilder>, XmlFile>)resource -> {
|
||||
PsiFile file = psiManager.findFile(resource.getFile());
|
||||
return file instanceof XmlFile ? (XmlFile)file : null;
|
||||
});
|
||||
return XmlSchemaHelper.getInstance().findNSFilesByURI(namespace, project, module);
|
||||
}
|
||||
|
||||
public static @Nullable XmlFile findXmlFile(@NotNull PsiFile base, @NotNull String uri) {
|
||||
|
||||
Reference in New Issue
Block a user