mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[devcontainers] IJPL-176636 Make workspace.xml machine-specific [IJ-CR-182127]
Squashed commits from devenv/ijpl-176636 (cherry picked from commit bdee2355abe858e4e4d78f17240644f3705fbd8c) IJ-CR-184127 GitOrigin-RevId: 3c10649b5bfcc10dae7d54db09994be21b8a86d8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
53fda21bb6
commit
d8d6ef73c7
@@ -50,6 +50,7 @@ jvm_library(
|
||||
"//platform/workspace/storage",
|
||||
"//libraries/kotlinx/serialization/json",
|
||||
"//platform/platform-impl/initial-config-import",
|
||||
"//platform/eel-provider",
|
||||
]
|
||||
)
|
||||
### auto-generated section `build intellij.platform.configurationStore.impl` end
|
||||
|
||||
@@ -44,5 +44,6 @@
|
||||
<orderEntry type="module" module-name="intellij.platform.workspace.storage" />
|
||||
<orderEntry type="module" module-name="intellij.libraries.kotlinx.serialization.json" />
|
||||
<orderEntry type="module" module-name="intellij.platform.ide.initialConfigImport" />
|
||||
<orderEntry type="module" module-name="intellij.platform.eel.provider" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -13,10 +13,14 @@ import com.intellij.openapi.components.impl.stores.IProjectStore
|
||||
import com.intellij.openapi.components.impl.stores.stateStore
|
||||
import com.intellij.openapi.diagnostic.getOrLogException
|
||||
import com.intellij.openapi.project.*
|
||||
import com.intellij.openapi.util.io.FileUtil.sanitizeFileName
|
||||
import com.intellij.openapi.util.io.FileUtilRt
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.openapi.vfs.ReadonlyStatusHandler
|
||||
import com.intellij.openapi.vfs.VfsUtilCore
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.platform.eel.provider.LocalEelMachine
|
||||
import com.intellij.platform.eel.provider.asEelPath
|
||||
import com.intellij.platform.settings.SettingsController
|
||||
import com.intellij.serviceContainer.ComponentManagerImpl
|
||||
import com.intellij.util.io.Ksuid
|
||||
@@ -36,6 +40,8 @@ internal const val VERSION_OPTION: String = "version"
|
||||
|
||||
internal const val PROJECT_CONFIG_DIR: String = $$"$PROJECT_CONFIG_DIR$"
|
||||
|
||||
private const val CONFIG_WORKSPACE_DIR = "workspace"
|
||||
|
||||
@ApiStatus.Internal
|
||||
open class ProjectStoreImpl(final override val project: Project) : ComponentStoreWithExtraComponents(), IProjectStore {
|
||||
override val isExternalStorageSupported: Boolean
|
||||
@@ -95,6 +101,8 @@ open class ProjectStoreImpl(final override val project: Project) : ComponentStor
|
||||
val iprFile: Path?
|
||||
val storeDescriptor = ProjectStorePathManager.getInstance().getStoreDescriptor(file)
|
||||
this.storeDescriptor = storeDescriptor
|
||||
val machineWorkspacePath = getMachineWorkspacePath(storeDescriptor)
|
||||
|
||||
if (storeDescriptor is IprProjectStoreDescriptor) {
|
||||
iprFile = file
|
||||
|
||||
@@ -102,7 +110,7 @@ open class ProjectStoreImpl(final override val project: Project) : ComponentStor
|
||||
|
||||
val userBaseDir = file.parent
|
||||
val workspacePath = userBaseDir.resolve("${file.fileName.toString().removeSuffix(ProjectFileType.DOT_DEFAULT_EXTENSION)}${WorkspaceFileType.DOT_DEFAULT_EXTENSION}")
|
||||
macros.add(Macro(StoragePathMacros.WORKSPACE_FILE, workspacePath))
|
||||
macros.add(Macro(StoragePathMacros.WORKSPACE_FILE, machineWorkspacePath ?: workspacePath))
|
||||
|
||||
if (isUnitTestMode) {
|
||||
// we don't load the default state in tests as the app store does, because:
|
||||
@@ -122,7 +130,7 @@ open class ProjectStoreImpl(final override val project: Project) : ComponentStor
|
||||
// PROJECT_CONFIG_DIR must be the first macro
|
||||
val dotIdea = storeDescriptor.dotIdea!!
|
||||
macros.add(Macro(PROJECT_CONFIG_DIR, dotIdea))
|
||||
macros.add(Macro(StoragePathMacros.WORKSPACE_FILE, dotIdea.resolve("workspace.xml")))
|
||||
macros.add(Macro(StoragePathMacros.WORKSPACE_FILE, machineWorkspacePath ?: dotIdea.resolve("workspace.xml")))
|
||||
macros.add(Macro(StoragePathMacros.PROJECT_FILE, dotIdea.resolve("misc.xml")))
|
||||
|
||||
if (isUnitTestMode) {
|
||||
@@ -170,9 +178,9 @@ open class ProjectStoreImpl(final override val project: Project) : ComponentStor
|
||||
else {
|
||||
PathManager.getConfigDir()
|
||||
}
|
||||
val productWorkspaceFile = basePath.resolve("workspace/$projectWorkspaceId.xml")
|
||||
val productWorkspaceFile = basePath.resolve("$CONFIG_WORKSPACE_DIR/$projectWorkspaceId.xml")
|
||||
// storageManager.setMacros(macros) was called before, because we need to read a `ProjectIdManager` state to get projectWorkspaceId
|
||||
macros.add(Macro(StoragePathMacros.PRODUCT_WORKSPACE_FILE, productWorkspaceFile))
|
||||
macros.add(Macro(StoragePathMacros.PRODUCT_WORKSPACE_FILE, machineWorkspacePath ?: productWorkspaceFile))
|
||||
}
|
||||
isStoreInitialized = true
|
||||
LOG.info("Project store initialized with paths: $macros")
|
||||
@@ -280,6 +288,13 @@ open class ProjectStoreImpl(final override val project: Project) : ComponentStor
|
||||
super.commitObsoleteComponents(session = session, isProjectLevel = true)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getMachineWorkspacePath(storeDescriptor: ProjectStoreDescriptor): Path? {
|
||||
val machine = storeDescriptor.historicalProjectBasePath.asEelPath().descriptor.machine
|
||||
if (machine is LocalEelMachine) return null
|
||||
val pathHash = FileUtilRt.pathHashCode(projectBasePath.invariantSeparatorsPathString)
|
||||
return PathManager.getOriginalConfigDir().resolve("$CONFIG_WORKSPACE_DIR/${sanitizeFileName(machine.name)}.${pathHash.toHexString()}.xml")
|
||||
}
|
||||
}
|
||||
|
||||
private class ProjectStateStorageManager(private val project: Project, private val isExternalStorageSupported: () -> Boolean) : StateStorageManagerImpl(
|
||||
|
||||
Reference in New Issue
Block a user