cleanup [*]: more efficient environment access

GitOrigin-RevId: 70d25c1e85f8b6aa205b94b0adff5fcc3ea80cd9
This commit is contained in:
Roman Shevchenko
2025-11-14 11:30:53 +00:00
committed by intellij-monorepo-bot
parent 55f56ddbb0
commit 2fad23c0d1
7 changed files with 16 additions and 23 deletions
@@ -69,7 +69,7 @@ public final class WSLUtil {
* @return root for WSL executable or null if unavailable
*/
private static @Nullable Path getExecutableRootPath() {
String localAppDataPath = System.getenv().get("LOCALAPPDATA");
String localAppDataPath = System.getenv("LOCALAPPDATA");
return StringUtil.isEmpty(localAppDataPath) ? null : Paths.get(localAppDataPath, "Microsoft\\WindowsApps");
}
@@ -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.warmup
import com.intellij.ide.environment.impl.EnvironmentUtil
@@ -217,7 +217,7 @@ private fun parseCommandLineArguments(args: List<String>): WarmupProjectArgs {
private suspend fun buildProject(project: Project, commandArgs: WarmupProjectArgs) {
val buildMode = getBuildMode(commandArgs)
val builders = System.getenv()["IJ_WARMUP_BUILD_BUILDERS"]?.split(";")?.toHashSet()
val builders = System.getenv("IJ_WARMUP_BUILD_BUILDERS")?.split(";")?.toHashSet()
if (buildMode != null) {
waitForBuilders(project, buildMode, builders)
}
@@ -259,4 +259,3 @@ private suspend fun exitApplication() {
ApplicationManager.getApplication().exit(false, true, false)
}
}
@@ -1,23 +1,17 @@
// 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.ide.startup.importSettings.db
import com.intellij.ide.startup.importSettings.providers.vswin.utilities.RunConfigurationEnvironmentUtils
import java.util.*
import com.intellij.util.EnvironmentUtil
object WindowsEnvVariables {
/*
* Some widely used env vars.
*/
val applicationData: String = get("APPDATA").toString()
val localApplicationData: String = get("LOCALAPPDATA").toString()
val userProfile: String = get("USERPROFILE").toString()
/**
* Function to get one Windows env var.
*
* Use without %%. Example: get("APPDATA")
* Some widely used env vars.
*/
fun get(variable: String): String? = System.getenv()[variable] ?: System.getenv()[variable.uppercase(Locale.getDefault())]
val applicationData: String = EnvironmentUtil.getValue("APPDATA").toString()
val localApplicationData: String = EnvironmentUtil.getValue("LOCALAPPDATA").toString()
val userProfile: String = EnvironmentUtil.getValue("USERPROFILE").toString()
fun expandPath(path: String): String? = RunConfigurationEnvironmentUtils.expandVariables("%", "%", path, WindowsEnvVariables::get, false, null)
}
fun expandPath(path: String): String? =
RunConfigurationEnvironmentUtils.expandVariables("%", "%", path, EnvironmentUtil::getValue, false, null)
}
@@ -26,7 +26,7 @@ envs {
String python312version = "3.12.0"
String python313version = "3.13.0"
def customBuildDir = System.getenv().get("PYCHARM_BUILD_DIR")
def customBuildDir = System.getenv("PYCHARM_BUILD_DIR")
project.buildDir = customBuildDir? new File(customBuildDir): buildDir
bootstrapDirectory = new File(buildDir, 'pythons')
envsDirectory = new File(buildDir, 'envs')
@@ -73,7 +73,7 @@ import static com.jetbrains.python.ast.PyAstFunction.Modifier.STATICMETHOD;
*/
public final class PyUtil {
private static final boolean VERBOSE_MODE = System.getenv().get("_PYCHARM_VERBOSE_MODE") != null;
private static final boolean VERBOSE_MODE = System.getenv("_PYCHARM_VERBOSE_MODE") != null;
private PyUtil() {
}
+1 -1
View File
@@ -12,7 +12,7 @@ envs {
envsDirectory = new File(System.getenv().getOrDefault("PYCHARM_PYTHON_VIRTUAL_ENVS", new File(buildDir, 'envs').path))
if (System.getenv().containsKey("PYCHARM_ZIP_REPOSITORY")) {
zipRepository = new URL(System.getenv().get("PYCHARM_ZIP_REPOSITORY"))
zipRepository = new URL(System.getenv("PYCHARM_ZIP_REPOSITORY"))
shouldUseZipsFromRepository = Os.isFamily(Os.FAMILY_WINDOWS)
}
+1 -1
View File
@@ -26,7 +26,7 @@ envs {
envsDirectory = new File(System.getenv().getOrDefault("PYCHARM_PYTHON_VIRTUAL_ENVS", new File(buildDir, 'envs').path))
if (System.getenv().containsKey("PYCHARM_ZIP_REPOSITORY")) {
zipRepository = new URL(System.getenv().get("PYCHARM_ZIP_REPOSITORY"))
zipRepository = new URL(System.getenv("PYCHARM_ZIP_REPOSITORY"))
shouldUseZipsFromRepository = Os.isFamily(Os.FAMILY_WINDOWS)
}