From 6039af1e68468b6912420e52f99a493988ef73ba Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Sun, 4 Aug 2024 15:30:12 +0200 Subject: [PATCH] IJPL-159596 cleanup - sort modifiers GitOrigin-RevId: a6c2e662d3a185b13847b586612bbc674ad2c3a7 --- .../references/ExternalResourceReference.java | 2 +- .../javaee/ExternalResourceManagerExImpl.kt | 23 ++++++------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/references/ExternalResourceReference.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/references/ExternalResourceReference.java index 02c15c6c636f..e9bc1826b2df 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/references/ExternalResourceReference.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/references/ExternalResourceReference.java @@ -63,7 +63,7 @@ final class ExternalResourceReference implements PsiReference, LocalQuickFixProv @Override public @Nullable PsiElement resolve() { String value = attribute.getValue(); - String resourceLocation = resourceManager.getResourceLocation(value, attribute.getProject()); + String resourceLocation = value == null ? null : resourceManager.getResourceLocation(value, attribute.getProject()); if (Objects.equals(resourceLocation, value)) { return null; } diff --git a/xml/xml-psi-impl/src/com/intellij/javaee/ExternalResourceManagerExImpl.kt b/xml/xml-psi-impl/src/com/intellij/javaee/ExternalResourceManagerExImpl.kt index 044a99f0c82f..dbe19ea8dda8 100644 --- a/xml/xml-psi-impl/src/com/intellij/javaee/ExternalResourceManagerExImpl.kt +++ b/xml/xml-psi-impl/src/com/intellij/javaee/ExternalResourceManagerExImpl.kt @@ -57,7 +57,6 @@ private val XSD_1_1 = ExternalResourceManagerExImpl.Resource( private const val HTML5_DOCTYPE_ELEMENT = "HTML5" private const val RESOURCE_ELEMENT: @NonNls String = "resource" -private const val URL_ATTR: @NonNls String = "url" private const val LOCATION_ATTR: @NonNls String = "location" private const val IGNORED_RESOURCE_ELEMENT: @NonNls String = "ignored-resource" private const val HTML_DEFAULT_DOCTYPE_ELEMENT: @NonNls String = "default-html-doctype" @@ -149,10 +148,9 @@ open class ExternalResourceManagerExImpl : ExternalResourceManagerEx(), Persiste return parent != null && parent.getName() == "standardSchemas" } - override fun isUserResource(file: VirtualFile): Boolean { - return resourceLocations.contains(file.getUrl()) - } + override fun isUserResource(file: VirtualFile): Boolean = resourceLocations.contains(file.url) + @Suppress("OVERRIDE_DEPRECATION") override fun getResourceLocation(url: String): String = getResourceLocation(url, DEFAULT_VERSION) override fun getResourceLocation(url: @NonNls String, version: String?): String { @@ -178,9 +176,7 @@ open class ExternalResourceManagerExImpl : ExternalResourceManagerEx(), Persiste } override fun getStdResource(url: String, version: String?): String? { - val map = getMap(standardResources.value, version) ?: return null - val resource = map.get(url) - return if (resource == null) null else resource.getResourceUrl() + return getMap(standardResources.value, version)?.get(url)?.getResourceUrl() } private fun getUserResource(url: String, version: String?): String? = getMap(resources, version)?.get(url) @@ -367,23 +363,17 @@ open class ExternalResourceManagerExImpl : ExternalResourceManagerEx(), Persiste return ArrayUtilRt.toStringArray(set) } - override fun getModificationCount(project: Project): Long { - return getProjectResources(project).getModificationCount() - } + override fun getModificationCount(project: Project): Long = getProjectResources(project).modificationCount override fun getState(): Element? { val element = Element("state") - val urls: MutableSet = TreeSet() + val urls = TreeSet() for (map in resources.values) { urls.addAll(map.keys) } for (url in urls) { - if (url == null) { - continue - } - val location = getResourceLocation(url) val e = Element(RESOURCE_ELEMENT) e.setAttribute(URL_ATTR, url) @@ -453,7 +443,7 @@ open class ExternalResourceManagerExImpl : ExternalResourceManagerEx(), Persiste } val catalogElement = state.getChild(CATALOG_PROPERTIES_ELEMENT) if (catalogElement != null) { - myCatalogPropertiesFile = catalogElement.getTextTrim() + myCatalogPropertiesFile = catalogElement.textTrim } } @@ -537,6 +527,7 @@ open class ExternalResourceManagerExImpl : ExternalResourceManagerEx(), Persiste return if (i > 0) file.substring(0, i) else file } + @Suppress("LoggingSimilarMessage") fun getResourceUrl(): String? { val resolvedResourcePath = resolvedResourcePath if (resolvedResourcePath != null) {