From f107566eafaf02d9a1b5fee87496b57a10960722 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 5 Aug 2025 23:05:53 +0200 Subject: [PATCH] Cleanup (inlining pointless property) GitOrigin-RevId: 8ae0758bf6f8b99a56e28962efc18d8fcbe3b3e5 --- .../server/LocalBuildCommandLineBuilder.java | 4 ++-- .../src/ApplicationStoreImpl.kt | 6 ++--- .../manage/ExternalProjectsDataStorage.java | 15 ++++++------ .../intellij/openapi/project/ProjectUtil.kt | 8 +++---- .../impl/DetectedFrameworksData.java | 6 ++--- .../intellij/ide/RecentProjectsManagerBase.kt | 4 ++-- .../statistics/impl/StatisticsManagerImpl.kt | 6 ++--- .../openapi/project/ProjectUtilTest.kt | 10 ++++---- .../openapi/application/pathManagerEx.kt | 24 ++++--------------- .../idea/KotlinFacetDeserializationTest.kt | 10 ++++---- .../jetbrains/idea/maven/utils/MavenUtil.kt | 6 +++-- .../api/PackageSearchApiClientService.kt | 4 ++-- 12 files changed, 44 insertions(+), 59 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/server/LocalBuildCommandLineBuilder.java b/java/compiler/impl/src/com/intellij/compiler/server/LocalBuildCommandLineBuilder.java index 824750a844c9..ca4bbfdceb13 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/LocalBuildCommandLineBuilder.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/LocalBuildCommandLineBuilder.java @@ -3,7 +3,7 @@ package com.intellij.compiler.server; import com.intellij.compiler.YourKitProfilerService; import com.intellij.execution.configurations.GeneralCommandLine; -import com.intellij.openapi.application.PathManagerEx; +import com.intellij.openapi.application.PathManager; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import org.jetbrains.annotations.NotNull; @@ -94,7 +94,7 @@ final class LocalBuildCommandLineBuilder implements BuildCommandLineBuilder { } static @NotNull Path getLocalBuildSystemDirectory() { - return PathManagerEx.getAppSystemDir().resolve(BuildManager.SYSTEM_ROOT); + return PathManager.getSystemDir().resolve(BuildManager.SYSTEM_ROOT); } static void setUnixProcessPriority(GeneralCommandLine commandLine, int priority) { diff --git a/platform/configuration-store-impl/src/ApplicationStoreImpl.kt b/platform/configuration-store-impl/src/ApplicationStoreImpl.kt index b9c94b450470..b6250c05e9a4 100644 --- a/platform/configuration-store-impl/src/ApplicationStoreImpl.kt +++ b/platform/configuration-store-impl/src/ApplicationStoreImpl.kt @@ -1,10 +1,10 @@ -// 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.configurationStore import com.intellij.configurationStore.schemeManager.ROOT_CONFIG import com.intellij.openapi.application.Application import com.intellij.openapi.application.PathManager -import com.intellij.openapi.application.appSystemDir +import com.intellij.openapi.application.PathManager.getSystemDir import com.intellij.openapi.application.impl.ApplicationImpl import com.intellij.openapi.components.ComponentManagerEx import com.intellij.openapi.components.PathMacroManager @@ -63,7 +63,7 @@ open class ApplicationStoreImpl(private val app: Application) : ComponentStoreWi // at first we must replace APP_CONFIG because it overlaps ROOT_CONFIG value Macro(APP_CONFIG, path.resolve(PathManager.OPTIONS_DIRECTORY)), Macro(ROOT_CONFIG, path), - Macro(StoragePathMacros.CACHE_FILE, appSystemDir.resolve("app-cache.xml")) + Macro(StoragePathMacros.CACHE_FILE, getSystemDir().resolve("app-cache.xml")) )) isStoreInitialized = true } diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ExternalProjectsDataStorage.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ExternalProjectsDataStorage.java index 9c2adbd89760..fc20f7525fbc 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ExternalProjectsDataStorage.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ExternalProjectsDataStorage.java @@ -7,7 +7,7 @@ import com.intellij.ide.SaveAndSyncHandler; import com.intellij.ide.plugins.DynamicPluginListener; import com.intellij.ide.plugins.IdeaPluginDescriptor; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.PathManagerEx; +import com.intellij.openapi.application.PathManager; import com.intellij.openapi.components.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.externalSystem.ExternalSystemManager; @@ -25,7 +25,6 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectUtil; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.SimpleModificationTracker; -import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.registry.Registry; import com.intellij.serialization.ObjectSerializer; import com.intellij.serialization.SerializationException; @@ -420,8 +419,8 @@ public final class ExternalProjectsDataStorage extends SimpleModificationTracker return true; } - File brokenMarkerFile = getBrokenMarkerFile(); - if (brokenMarkerFile.exists() && lastModified < brokenMarkerFile.lastModified()) { + var brokenMarkerFile = getBrokenMarkerFile(); + if (Files.exists(brokenMarkerFile) && lastModified < Files.getLastModifiedTime(brokenMarkerFile).toMillis()) { Files.delete(configurationFile); return true; } @@ -476,17 +475,17 @@ public final class ExternalProjectsDataStorage extends SimpleModificationTracker public static synchronized void invalidateCaches() { if (!Registry.is("external.system.invalidate.storage", true)) return; - File markerFile = getBrokenMarkerFile(); + var markerFile = getBrokenMarkerFile(); try { - FileUtil.writeToFile(markerFile, String.valueOf(System.currentTimeMillis())); + Files.writeString(markerFile, String.valueOf(System.currentTimeMillis())); } catch (IOException e) { LOG.warn("Cannot update the invalidation marker file", e); } } - private static @NotNull File getBrokenMarkerFile() { - return PathManagerEx.getAppSystemDir().resolve("external_build_system").resolve(".broken").toFile(); + private static @NotNull Path getBrokenMarkerFile() { + return PathManager.getSystemDir().resolve("external_build_system").resolve(".broken"); } static final class State { diff --git a/platform/ide-core/src/com/intellij/openapi/project/ProjectUtil.kt b/platform/ide-core/src/com/intellij/openapi/project/ProjectUtil.kt index bcc94f388f6c..477e0b1066e0 100644 --- a/platform/ide-core/src/com/intellij/openapi/project/ProjectUtil.kt +++ b/platform/ide-core/src/com/intellij/openapi/project/ProjectUtil.kt @@ -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. @file:JvmName("ProjectUtil") package com.intellij.openapi.project @@ -6,7 +6,7 @@ import com.intellij.ide.DataManager import com.intellij.ide.highlighter.ProjectFileType import com.intellij.openapi.actionSystem.CommonDataKeys import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.application.appSystemDir +import com.intellij.openapi.application.PathManager.getSystemDir import com.intellij.openapi.fileEditor.UniqueVFilePathBuilder import com.intellij.openapi.fileTypes.FileType import com.intellij.openapi.fileTypes.FileTypeManager @@ -210,7 +210,7 @@ fun getProjectCacheFileName(presentableUrl: String?, */ @JvmOverloads fun Project.getProjectCachePath(@NonNls cacheDirName: String, isForceNameUse: Boolean = false, extensionWithDot: String = ""): Path { - return appSystemDir.resolve(cacheDirName).resolve(getProjectCacheFileName(isForceNameUse, extensionWithDot = extensionWithDot)) + return getSystemDir().resolve(cacheDirName).resolve(getProjectCacheFileName(isForceNameUse, extensionWithDot = extensionWithDot)) } /** @@ -230,7 +230,7 @@ fun Project.getProjectDataPath(@NonNls name: String): Path { * Root directory for all project-specific caches. */ val projectsDataDir: Path - get() = appSystemDir.resolve("projects") + get() = getSystemDir().resolve("projects") /** * Asynchronously deletes caches directories obtained via [getProjectDataPath] for all projects. diff --git a/platform/lang-impl/src/com/intellij/framework/detection/impl/DetectedFrameworksData.java b/platform/lang-impl/src/com/intellij/framework/detection/impl/DetectedFrameworksData.java index 230b50466717..cd013df6797a 100644 --- a/platform/lang-impl/src/com/intellij/framework/detection/impl/DetectedFrameworksData.java +++ b/platform/lang-impl/src/com/intellij/framework/detection/impl/DetectedFrameworksData.java @@ -1,8 +1,8 @@ -// 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.framework.detection.impl; import com.intellij.framework.detection.DetectedFrameworkDescription; -import com.intellij.openapi.application.PathManagerEx; +import com.intellij.openapi.application.PathManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectUtil; @@ -146,6 +146,6 @@ public final class DetectedFrameworksData { } private static @NotNull Path getDetectionDirPath() { - return PathManagerEx.getAppSystemDir().resolve("frameworks").resolve("detection"); + return PathManager.getSystemDir().resolve("frameworks").resolve("detection"); } } diff --git a/platform/platform-impl/src/com/intellij/ide/RecentProjectsManagerBase.kt b/platform/platform-impl/src/com/intellij/ide/RecentProjectsManagerBase.kt index fcf4e1bdbdfe..5109b0de12fe 100644 --- a/platform/platform-impl/src/com/intellij/ide/RecentProjectsManagerBase.kt +++ b/platform/platform-impl/src/com/intellij/ide/RecentProjectsManagerBase.kt @@ -16,7 +16,7 @@ import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.EDT import com.intellij.openapi.application.PathManager -import com.intellij.openapi.application.appSystemDir +import com.intellij.openapi.application.PathManager.getSystemDir import com.intellij.openapi.application.ex.ApplicationInfoEx import com.intellij.openapi.application.ex.ApplicationManagerEx import com.intellij.openapi.components.* @@ -1001,7 +1001,7 @@ private fun readProjectName(path: String): String { return JpsPathUtil.readProjectName(storePath) ?: PathUtilRt.getFileName(path) } -private fun getLastProjectFrameInfoFile() = appSystemDir.resolve("lastProjectFrameInfo") +private fun getLastProjectFrameInfoFile() = getSystemDir().resolve("lastProjectFrameInfo") private fun convertToSystemIndependentPaths(list: MutableList) { list.replaceAll { diff --git a/platform/platform-impl/src/com/intellij/psi/statistics/impl/StatisticsManagerImpl.kt b/platform/platform-impl/src/com/intellij/psi/statistics/impl/StatisticsManagerImpl.kt index 3e83526b4a56..a3c1efee299f 100644 --- a/platform/platform-impl/src/com/intellij/psi/statistics/impl/StatisticsManagerImpl.kt +++ b/platform/platform-impl/src/com/intellij/psi/statistics/impl/StatisticsManagerImpl.kt @@ -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.psi.statistics.impl import com.intellij.CommonBundle @@ -6,7 +6,7 @@ import com.intellij.configurationStore.SettingsSavingComponent import com.intellij.ide.IdeBundle import com.intellij.openapi.Disposable import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.application.appSystemDir +import com.intellij.openapi.application.PathManager.getSystemDir import com.intellij.openapi.ui.Messages import com.intellij.openapi.util.Disposer import com.intellij.psi.statistics.StatisticsInfo @@ -175,4 +175,4 @@ private fun getUnitNumber(key1: String) = abs(key1.hashCode() % UNIT_COUNT) private fun getPathToUnit(unitNumber: Int) = storeDir.resolve("unit.$unitNumber") private val storeDir: Path - get() = appSystemDir.resolve("stat") + get() = getSystemDir().resolve("stat") diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/project/ProjectUtilTest.kt b/platform/platform-tests/testSrc/com/intellij/openapi/project/ProjectUtilTest.kt index 162c0b500beb..37d2d022d4fc 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/project/ProjectUtilTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/openapi/project/ProjectUtilTest.kt @@ -1,7 +1,7 @@ -// 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-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.openapi.project -import com.intellij.openapi.application.appSystemDir +import com.intellij.openapi.application.PathManager.getSystemDir import com.intellij.openapi.project.ex.ProjectEx import com.intellij.openapi.project.ex.ProjectManagerEx import com.intellij.testFramework.ApplicationRule @@ -31,7 +31,7 @@ class ProjectUtilTest { project.useProject { project.setProjectName("do not use me") - val cachePath = appSystemDir.relativize(project.getProjectCachePath("foo")).toString() + val cachePath = getSystemDir().relativize(project.getProjectCachePath("foo")).toString() // remove location hash suffix because it is not constant value (depends on machine) assertThat(cachePath.substring(0, cachePath.lastIndexOf('.'))) .isEqualTo("foo${File.separatorChar}p") @@ -45,10 +45,10 @@ class ProjectUtilTest { project.useProject { project.setProjectName("World of heavens | Client") - val cachePath = appSystemDir.relativize(project.getProjectCachePath("test", isForceNameUse = true)).toString() + val cachePath = getSystemDir().relativize(project.getProjectCachePath("test", isForceNameUse = true)).toString() // remove location hash suffix because it is not constant value (depends on machine) assertThat(cachePath.substring(0, cachePath.lastIndexOf('.'))) .isEqualTo("test${File.separatorChar}World of heavens _ Client") } } -} \ No newline at end of file +} diff --git a/platform/util-ex/src/com/intellij/openapi/application/pathManagerEx.kt b/platform/util-ex/src/com/intellij/openapi/application/pathManagerEx.kt index 595d74d2194b..0ad47902f77f 100644 --- a/platform/util-ex/src/com/intellij/openapi/application/pathManagerEx.kt +++ b/platform/util-ex/src/com/intellij/openapi/application/pathManagerEx.kt @@ -1,25 +1,9 @@ -// 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. @file:JvmName("PathManagerEx") package com.intellij.openapi.application -import com.intellij.openapi.diagnostic.logger -import java.io.IOException -import java.nio.file.NoSuchFileException import java.nio.file.Path -/** - * Absolute canonical path to system cache dir. - */ -val appSystemDir: Path - get() { - val path = PathManager.getSystemDir() - try { - return path.toRealPath() - } - catch (ignore: NoSuchFileException) { - } - catch (e: IOException) { - logger().warn(e) - } - return path - } +@Deprecated("Pointless; use `PathManager.getSystemDir()` instead", replaceWith = ReplaceWith("PathManager.getSystemDir()"), level = DeprecationLevel.ERROR) +@Suppress("unused") +val appSystemDir: Path get() = PathManager.getSystemDir() diff --git a/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetDeserializationTest.kt b/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetDeserializationTest.kt index d5a45a9c6f5a..dc174f5d0a39 100644 --- a/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetDeserializationTest.kt +++ b/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetDeserializationTest.kt @@ -1,10 +1,10 @@ -// 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 org.jetbrains.kotlin.idea import com.intellij.facet.Facet import com.intellij.facet.FacetManager -import com.intellij.openapi.application.appSystemDir +import com.intellij.openapi.application.PathManager.getSystemDir import com.intellij.openapi.module.ModuleManager import com.intellij.openapi.project.Project import com.intellij.openapi.project.doNotEnableExternalStorageByDefaultInTests @@ -185,8 +185,8 @@ class KotlinFacetDeserializationTest { } val testCacheFilesDir = testDataRoot.resolve(testDataDirName).resolve("external").toFile() if (testCacheFilesDir.exists()) { - val cachePath = appSystemDir - .resolve("projects") + val cachePath = getSystemDir() + .resolve("projects") .resolve(getProjectCacheFileName(dir.toNioPath())) .resolve("external_build_system") FileUtil.copyDir(testCacheFilesDir, cachePath.toFile()) @@ -203,4 +203,4 @@ class KotlinFacetDeserializationTest { } } } -} \ No newline at end of file +} diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.kt b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.kt index 3774ddd0b4ae..ac6760f36218 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.kt +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.kt @@ -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 org.jetbrains.idea.maven.utils import com.intellij.codeInsight.actions.ReformatCodeProcessor @@ -14,6 +14,8 @@ import com.intellij.notification.Notification import com.intellij.notification.NotificationType import com.intellij.notification.Notifications import com.intellij.openapi.application.* +import com.intellij.openapi.application.PathManager +import com.intellij.openapi.application.PathManager.getSystemDir import com.intellij.openapi.application.impl.ApplicationInfoImpl import com.intellij.openapi.application.impl.LaterInvocator import com.intellij.openapi.externalSystem.ExternalSystemModulePropertyManager.Companion.getInstance @@ -334,7 +336,7 @@ object MavenUtil { @JvmStatic fun getPluginSystemDir(folder: String): Path { - return appSystemDir.resolve("Maven").resolve(folder) + return getSystemDir().resolve("Maven").resolve(folder) } @JvmStatic diff --git a/plugins/repository-search/src/main/kotlin/org/jetbrains/idea/packagesearch/api/PackageSearchApiClientService.kt b/plugins/repository-search/src/main/kotlin/org/jetbrains/idea/packagesearch/api/PackageSearchApiClientService.kt index 3a2c7533a96d..1f31b0d6c66e 100644 --- a/plugins/repository-search/src/main/kotlin/org/jetbrains/idea/packagesearch/api/PackageSearchApiClientService.kt +++ b/plugins/repository-search/src/main/kotlin/org/jetbrains/idea/packagesearch/api/PackageSearchApiClientService.kt @@ -4,7 +4,7 @@ import com.intellij.openapi.Disposable import com.intellij.openapi.application.ApplicationInfo import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.ApplicationNamesInfo -import com.intellij.openapi.application.appSystemDir +import com.intellij.openapi.application.PathManager.getSystemDir import com.intellij.openapi.components.Service import com.intellij.openapi.util.registry.Registry import com.intellij.util.io.createParentDirectories @@ -82,7 +82,7 @@ class PackageSearchApiClientService(val coroutineScope: CoroutineScope) : Dispos } private val cacheFilePath - get() = appSystemDir / "caches" / "packagesearch" / "${PackageSearchApiClientObject.version}.db" + get() = getSystemDir() / "caches" / "packagesearch" / "${PackageSearchApiClientObject.version}.db" private val mvDataStore = MVDataStore.open(