mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
BAZEL-2160 cleanup
GitOrigin-RevId: 7d96e5f37c28adf8651a57ebc23b295da9b4f24d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b24bd9b6b2
commit
cea2e2e7be
+5
-2
@@ -1,4 +1,6 @@
|
||||
// Copyright 2000-2021 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.
|
||||
@file:Suppress("ReplacePutWithAssignment", "ReplaceGetOrSet")
|
||||
|
||||
package com.intellij.compiler
|
||||
|
||||
import com.intellij.openapi.components.PersistentStateComponent
|
||||
@@ -22,8 +24,9 @@ internal class ExternalCompilerConfigurationStorage(private val project: Project
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun getInstance(project: Project): ExternalCompilerConfigurationStorage =
|
||||
project.getService(ExternalCompilerConfigurationStorage::class.java)
|
||||
fun getInstance(project: Project): ExternalCompilerConfigurationStorage {
|
||||
return project.getService(ExternalCompilerConfigurationStorage::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getState(): Element {
|
||||
|
||||
+6
-5
@@ -13,13 +13,14 @@ import org.jetbrains.jps.model.java.compiler.JpsJavaCompilerOptions;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("LightServiceMigrationCode")
|
||||
@State(name = "JavacSettings", storages = @Storage("compiler.xml"))
|
||||
public class JavacConfiguration implements PersistentStateComponent<JpsJavaCompilerOptions> {
|
||||
public final class JavacConfiguration implements PersistentStateComponent<JpsJavaCompilerOptions> {
|
||||
private final JpsJavaCompilerOptions mySettings = new JpsJavaCompilerOptions();
|
||||
private final Project myProject;
|
||||
private final Project project;
|
||||
|
||||
public JavacConfiguration(Project project) {
|
||||
myProject = project;
|
||||
public JavacConfiguration(@NotNull Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -27,7 +28,7 @@ public class JavacConfiguration implements PersistentStateComponent<JpsJavaCompi
|
||||
final JpsJavaCompilerOptions state = new JpsJavaCompilerOptions();
|
||||
XmlSerializerUtil.copyBean(mySettings, state);
|
||||
state.ADDITIONAL_OPTIONS_OVERRIDE = new HashMap<>(state.ADDITIONAL_OPTIONS_OVERRIDE); // copyBean copies by reference, we need a map clone here
|
||||
final PathMacroManager macros = PathMacroManager.getInstance(myProject);
|
||||
final PathMacroManager macros = PathMacroManager.getInstance(project);
|
||||
state.ADDITIONAL_OPTIONS_STRING = macros.collapsePathsRecursively(state.ADDITIONAL_OPTIONS_STRING);
|
||||
for (Map.Entry<String, String> entry : state.ADDITIONAL_OPTIONS_OVERRIDE.entrySet()) {
|
||||
entry.setValue(macros.collapsePathsRecursively(entry.getValue()));
|
||||
|
||||
@@ -133,10 +133,11 @@ internal fun getEffectiveRoamingType(roamingType: RoamingType, collapsedPath: St
|
||||
}
|
||||
}
|
||||
|
||||
internal fun isSpecialOrNonRoamableStorage(collapsedPath: String): Boolean =
|
||||
collapsedPath == StoragePathMacros.WORKSPACE_FILE ||
|
||||
collapsedPath == StoragePathMacros.NON_ROAMABLE_FILE ||
|
||||
isSpecialStorage(collapsedPath)
|
||||
internal fun isSpecialOrNonRoamableStorage(collapsedPath: String): Boolean {
|
||||
return collapsedPath == StoragePathMacros.WORKSPACE_FILE ||
|
||||
collapsedPath == StoragePathMacros.NON_ROAMABLE_FILE ||
|
||||
isSpecialStorage(collapsedPath)
|
||||
}
|
||||
|
||||
internal fun isSpecialStorage(collapsedPath: String): Boolean {
|
||||
return collapsedPath == StoragePathMacros.CACHE_FILE || collapsedPath == StoragePathMacros.PRODUCT_WORKSPACE_FILE
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.intellij.openapi.util.JDOMUtil
|
||||
import com.intellij.openapi.util.NlsSafe
|
||||
import com.intellij.openapi.util.Pair
|
||||
import com.intellij.openapi.util.SystemInfoRt
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.util.io.FileUtilRt
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.openapi.vfs.VirtualFileManager
|
||||
@@ -86,7 +85,7 @@ class ProjectWithModuleStoreImpl(project: Project) : ProjectStoreImpl(project),
|
||||
saveSessions: MutableList<SaveSession>,
|
||||
saveResult: SaveResult,
|
||||
forceSavingAllSettings: Boolean,
|
||||
projectSessionManager: ProjectSaveSessionProducerManager
|
||||
projectSessionManager: ProjectSaveSessionProducerManager,
|
||||
) {
|
||||
projectSessionManager as ProjectWithModulesSaveSessionProducerManager
|
||||
val workspaceModel = project.serviceAsync<WorkspaceModel>()
|
||||
@@ -376,16 +375,14 @@ private class ProjectWithModulesSaveSessionProducerManager(project: Project, isU
|
||||
fun commitComponents(moduleStore: ComponentStoreImpl, moduleSaveSessionManager: SaveSessionProducerManager) {
|
||||
fun commitToStorage(storageSpec: Storage, componentToElement: Map<String, Element>) {
|
||||
val storage = moduleStore.storageManager.getStateStorage(storageSpec)
|
||||
val producer = moduleSaveSessionManager.getProducer(storage)
|
||||
if (producer != null) {
|
||||
for ((componentName, componentTag) in componentToElement) {
|
||||
producer.setState(
|
||||
component = null,
|
||||
componentName = componentName,
|
||||
pluginId = PluginManagerCore.CORE_ID,
|
||||
state = if (componentTag === NULL_ELEMENT) null else componentTag,
|
||||
)
|
||||
}
|
||||
val producer = moduleSaveSessionManager.getProducer(storage) ?: return
|
||||
for ((componentName, componentTag) in componentToElement) {
|
||||
producer.setState(
|
||||
component = null,
|
||||
componentName = componentName,
|
||||
pluginId = PluginManagerCore.CORE_ID,
|
||||
state = if (componentTag === NULL_ELEMENT) null else componentTag,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -415,40 +412,40 @@ internal class StorageJpsConfigurationReader(private val project: Project, priva
|
||||
if (ProjectUtil.isRemotePath(FileUtilRt.toSystemDependentName(filePath)) && !TrustedProjects.isProjectTrusted(project)) {
|
||||
throw IOException(ConfigurationStoreBundle.message("error.message.details.configuration.files.from.remote.locations.in.safe.mode"))
|
||||
}
|
||||
if (componentName.isEmpty()) {
|
||||
//this is currently used for loading Eclipse project configuration from the.classpath file
|
||||
val file = VirtualFileManager.getInstance().findFileByUrl(fileUrl)
|
||||
val component = file?.inputStream?.use { JDOMUtil.load(it) }
|
||||
return@addMeasuredTime component
|
||||
}
|
||||
if (isExternalMiscFile(filePath)) {
|
||||
// this is a workaround to make a working scenario when the whole .idea is moved to external configuration dir
|
||||
// see com.intellij.workspaceModel.ide.impl.jps.serialization.JpsProjectEntitiesLoader.isExternalStorageEnabled
|
||||
val component = getCachingReader().loadComponent(fileUrl, componentName, customModuleFilePath)
|
||||
return@addMeasuredTime component
|
||||
}
|
||||
if (filePath.endsWith(".iml") || isExternalModuleFile(filePath)) {
|
||||
//todo fetch data from ModuleStore (IJPL-15992)
|
||||
val component = getCachingReader().loadComponent(fileUrl, componentName, customModuleFilePath)
|
||||
return@addMeasuredTime component
|
||||
}
|
||||
else {
|
||||
val storage = getProjectStateStorage(filePath, project.stateStore, project)
|
||||
val stateMap = storage.getStorageData()
|
||||
val component = if (storage is DirectoryBasedStorage) {
|
||||
val elementContent = stateMap.getElement(PathUtilRt.getFileName(filePath))
|
||||
if (elementContent == null) {
|
||||
null
|
||||
|
||||
when {
|
||||
componentName.isEmpty() -> {
|
||||
// this is currently used for loading Eclipse project configuration from the.classpath file
|
||||
val file = VirtualFileManager.getInstance().findFileByUrl(fileUrl)
|
||||
file?.inputStream?.use { JDOMUtil.load(it) }
|
||||
}
|
||||
isExternalMiscFile(filePath) -> {
|
||||
// this is a workaround to make a working scenario when the whole .idea is moved to external configuration dir
|
||||
// see com.intellij.workspaceModel.ide.impl.jps.serialization.JpsProjectEntitiesLoader.isExternalStorageEnabled
|
||||
getCachingReader().loadComponent(fileUrl, componentName, customModuleFilePath)
|
||||
}
|
||||
filePath.endsWith(".iml") || isExternalModuleFile(filePath) -> {
|
||||
//todo fetch data from ModuleStore (IJPL-15992)
|
||||
getCachingReader().loadComponent(fileUrl, componentName, customModuleFilePath)
|
||||
}
|
||||
else -> {
|
||||
val storage = getProjectStateStorage(filePath, project.stateStore, project)
|
||||
val stateMap = storage.getStorageData()
|
||||
val component = if (storage is DirectoryBasedStorage) {
|
||||
val elementContent = stateMap.getElement(PathUtilRt.getFileName(filePath))
|
||||
if (elementContent == null) {
|
||||
null
|
||||
}
|
||||
else {
|
||||
Element(ComponentStorageUtil.COMPONENT).setAttribute(ComponentStorageUtil.NAME, componentName).addContent(elementContent)
|
||||
}
|
||||
}
|
||||
else {
|
||||
Element(ComponentStorageUtil.COMPONENT).setAttribute(ComponentStorageUtil.NAME, componentName).addContent(elementContent)
|
||||
stateMap.getElement(componentName)
|
||||
}
|
||||
}
|
||||
else {
|
||||
stateMap.getElement(componentName)
|
||||
}
|
||||
|
||||
return@addMeasuredTime component
|
||||
component
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -493,19 +490,18 @@ internal class StorageJpsConfigurationReader(private val project: Project, priva
|
||||
}
|
||||
|
||||
internal fun getProjectStateStorage(filePath: String, store: IProjectStore, project: Project): StateStorageBase<StateMap> {
|
||||
val storageSpec = getStorageSpec(filePath, project)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return store.storageManager.getStateStorage(storageSpec) as StateStorageBase<StateMap>
|
||||
return store.storageManager.getStateStorage(getStorageSpec(filePath, project)) as StateStorageBase<StateMap>
|
||||
}
|
||||
|
||||
private fun getStorageSpec(filePath: String, project: Project): Storage {
|
||||
val collapsedPath: String
|
||||
val splitterClass: Class<out StateSplitterEx>
|
||||
val fileName = PathUtil.getFileName(filePath)
|
||||
val parentPath = PathUtil.getParentPath(filePath)
|
||||
val parentFileName = PathUtil.getFileName(parentPath)
|
||||
if (filePath.endsWith(".ipr") || fileName == "misc.xml" && parentFileName == Project.DIRECTORY_STORE_FOLDER) {
|
||||
collapsedPath = "\$PROJECT_FILE$"
|
||||
val fileName = PathUtilRt.getFileName(filePath)
|
||||
val parentPath = PathUtilRt.getParentPath(filePath)
|
||||
val parentFileName = PathUtilRt.getFileName(parentPath)
|
||||
if (filePath.endsWith(".ipr") || (fileName == "misc.xml" && parentFileName == Project.DIRECTORY_STORE_FOLDER)) {
|
||||
collapsedPath = $$"$PROJECT_FILE$"
|
||||
splitterClass = StateSplitterEx::class.java
|
||||
}
|
||||
else {
|
||||
@@ -514,13 +510,13 @@ private fun getStorageSpec(filePath: String, project: Project): Storage {
|
||||
splitterClass = StateSplitterEx::class.java
|
||||
}
|
||||
else {
|
||||
val grandParentPath = PathUtil.getParentPath(parentPath)
|
||||
val grandParentPath = PathUtilRt.getParentPath(parentPath)
|
||||
collapsedPath = parentFileName
|
||||
splitterClass = FakeDirectoryBasedStateSplitter::class.java
|
||||
if (PathUtil.getFileName(grandParentPath) != Project.DIRECTORY_STORE_FOLDER) {
|
||||
if (parentFileName == "project") {
|
||||
if (fileName == "libraries.xml" || fileName == "artifacts.xml") {
|
||||
val inProjectStorage = FileStorageAnnotation(FileUtil.getNameWithoutExtension(fileName), false, splitterClass)
|
||||
val inProjectStorage = FileStorageAnnotation(FileUtilRt.getNameWithoutExtension(fileName), false, splitterClass)
|
||||
val componentName = if (fileName == "libraries.xml") "libraryTable" else "ArtifactManager"
|
||||
StreamProviderFactory.EP_NAME.computeSafeIfAny(project) {
|
||||
it.getOrCreateStorageSpec(fileName, StateAnnotation(componentName, inProjectStorage))
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// Copyright 2000-2024 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.configurationStore
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
@@ -18,7 +20,7 @@ internal open class SaveSessionProducerManager(private val isUseVfsForWrite: Boo
|
||||
private val producers = Collections.synchronizedMap(LinkedHashMap<StateStorage, SaveSessionProducer>())
|
||||
|
||||
fun getProducer(storage: StateStorage): SaveSessionProducer? {
|
||||
var producer = producers[storage]
|
||||
var producer = producers.get(storage)
|
||||
if (producer == null) {
|
||||
producer = storage.createSaveSessionProducer() ?: return null
|
||||
val prev = producers.put(storage, producer)
|
||||
|
||||
+15
-10
@@ -23,8 +23,9 @@ internal class ExternalModuleStorage(private val module: Module, storageManager:
|
||||
|
||||
override fun loadLocalData(): Element? = manager.readModuleData(module.name)
|
||||
|
||||
override fun createSaveSession(states: StateMap): SaveSessionProducer =
|
||||
ExternalStorageSaveSessionProducer(states, storage = this, manager.moduleStorage, module.name)
|
||||
override fun createSaveSession(states: StateMap): SaveSessionProducer {
|
||||
return ExternalStorageSaveSessionProducer(states, storage = this, manager.moduleStorage, module.name)
|
||||
}
|
||||
}
|
||||
|
||||
internal open class ExternalProjectStorage(
|
||||
@@ -40,8 +41,9 @@ internal open class ExternalProjectStorage(
|
||||
|
||||
override fun loadLocalData(): Element? = manager.fileStorage.read(fileSpec)
|
||||
|
||||
override fun createSaveSession(states: StateMap): SaveSessionProducer =
|
||||
ExternalStorageSaveSessionProducer(states, storage = this, manager.fileStorage, name = fileSpec)
|
||||
override fun createSaveSession(states: StateMap): SaveSessionProducer {
|
||||
return ExternalStorageSaveSessionProducer(states, storage = this, manager.fileStorage, name = fileSpec)
|
||||
}
|
||||
|
||||
override fun toString(): String = "ExternalProjectStorage(fileSpec=${fileSpec})"
|
||||
}
|
||||
@@ -64,19 +66,22 @@ internal class ExternalProjectFilteringStorage(
|
||||
override fun hasData(element: Element): Boolean = element.children.any { elementOutputFilter.accept(it, 1) }
|
||||
}
|
||||
|
||||
override fun loadLocalData(): Element? =
|
||||
JDOMUtil.merge(
|
||||
override fun loadLocalData(): Element? {
|
||||
return JDOMUtil.merge(
|
||||
super.loadLocalData(),
|
||||
internalStorage.getSerializedState(internalStorage.loadData(), component = null, componentName, archive = true)
|
||||
)
|
||||
}
|
||||
|
||||
override fun createSaveSession(states: StateMap): SaveSessionProducer =
|
||||
ExternalStorageSaveSessionProducer(states, storage = this, manager.fileStorage, name = fileSpec, filter)
|
||||
override fun createSaveSession(states: StateMap): SaveSessionProducer {
|
||||
return ExternalStorageSaveSessionProducer(states, storage = this, manager.fileStorage, name = fileSpec, filter)
|
||||
}
|
||||
}
|
||||
|
||||
private fun findExternalSystemStreamProviderFactory(project: Project): ExternalSystemStreamProviderFactory =
|
||||
StreamProviderFactory.EP_NAME.getExtensions(project)
|
||||
private fun findExternalSystemStreamProviderFactory(project: Project): ExternalSystemStreamProviderFactory {
|
||||
return StreamProviderFactory.EP_NAME.getExtensions(project)
|
||||
.first { it is ExternalSystemStreamProviderFactory } as ExternalSystemStreamProviderFactory
|
||||
}
|
||||
|
||||
private class ExternalStorageSaveSessionProducer(
|
||||
states: StateMap,
|
||||
|
||||
+8
-3
@@ -15,7 +15,6 @@ import com.intellij.openapi.roots.ProjectModelElement
|
||||
import com.intellij.openapi.startup.StartupManager
|
||||
import com.intellij.util.Function
|
||||
import org.jdom.Element
|
||||
import java.util.*
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock
|
||||
import kotlin.concurrent.read
|
||||
@@ -32,7 +31,7 @@ internal class ExternalSystemStreamProviderFactory(private val project: Project)
|
||||
private val storages = HashMap<String, Storage>()
|
||||
|
||||
init {
|
||||
project.messageBus.connect().subscribe(ModuleListener.TOPIC, object : ModuleListener {
|
||||
project.messageBus.simpleConnect().subscribe(ModuleListener.TOPIC, object : ModuleListener {
|
||||
override fun moduleRemoved(project: Project, module: Module) {
|
||||
moduleStorage.remove(module.name)
|
||||
}
|
||||
@@ -45,7 +44,13 @@ internal class ExternalSystemStreamProviderFactory(private val project: Project)
|
||||
})
|
||||
}
|
||||
|
||||
override fun customizeStorageSpecs(component: PersistentStateComponent<*>, storageManager: StateStorageManager, stateSpec: State, storages: List<Storage>, operation: StateStorageOperation): List<Storage>? {
|
||||
override fun customizeStorageSpecs(
|
||||
component: PersistentStateComponent<*>,
|
||||
storageManager: StateStorageManager,
|
||||
stateSpec: State,
|
||||
storages: List<Storage>,
|
||||
operation: StateStorageOperation,
|
||||
): List<Storage>? {
|
||||
val componentManager = storageManager.componentManager ?: return null
|
||||
val project = componentManager as? Project ?: (componentManager as Module).project
|
||||
|
||||
|
||||
+10
-8
@@ -1,4 +1,6 @@
|
||||
// Copyright 2000-2024 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.workspaceModel.ide.impl.jps.serialization
|
||||
|
||||
import com.intellij.openapi.components.ExpandMacroToPathMap
|
||||
@@ -7,7 +9,6 @@ import com.intellij.openapi.components.impl.ModulePathMacroManager
|
||||
import com.intellij.openapi.components.impl.ProjectPathMacroManager
|
||||
import com.intellij.openapi.components.impl.stores.ComponentStorageUtil
|
||||
import com.intellij.openapi.util.JDOMUtil
|
||||
import com.intellij.openapi.util.text.Strings
|
||||
import com.intellij.platform.workspace.jps.JpsProjectConfigLocation
|
||||
import com.intellij.platform.workspace.jps.bridge.impl.serialization.DefaultImlNormalizer
|
||||
import com.intellij.platform.workspace.jps.serialization.impl.JpsFileContentReader
|
||||
@@ -32,11 +33,12 @@ class CachingJpsFileContentReader(private val configLocation: JpsProjectConfigLo
|
||||
val content = fileContentCache.computeIfAbsent(fileUrl + customModuleFilePath) {
|
||||
loadComponents(fileUrl, customModuleFilePath)
|
||||
}
|
||||
return content[componentName]
|
||||
return content.get(componentName)
|
||||
}
|
||||
|
||||
override fun getExpandMacroMap(fileUrl: String): ExpandMacroToPathMap =
|
||||
getMacroManager(fileUrl = fileUrl, customModuleFilePath = null).expandMacroMap
|
||||
override fun getExpandMacroMap(fileUrl: String): ExpandMacroToPathMap {
|
||||
return getMacroManager(fileUrl = fileUrl, customModuleFilePath = null).expandMacroMap
|
||||
}
|
||||
|
||||
private fun loadComponents(fileUrl: String, customModuleFilePath: String?): Map<String, Element> {
|
||||
val macroManager = getMacroManager(fileUrl = fileUrl, customModuleFilePath = customModuleFilePath)
|
||||
@@ -46,17 +48,17 @@ class CachingJpsFileContentReader(private val configLocation: JpsProjectConfigLo
|
||||
|
||||
private fun getMacroManager(fileUrl: String, customModuleFilePath: String?): PathMacroManager {
|
||||
val path = JpsPathUtil.urlToPath(fileUrl)
|
||||
return if (fileUrl.endsWith(".iml") || isExternalModuleFile(path)) {
|
||||
ModulePathMacroManager.createInstance(configLocation::projectFilePath) { customModuleFilePath ?: path }
|
||||
if (fileUrl.endsWith(".iml") || isExternalModuleFile(path)) {
|
||||
return ModulePathMacroManager.createInstance(configLocation::projectFilePath) { customModuleFilePath ?: path }
|
||||
}
|
||||
else {
|
||||
projectPathMacroManager
|
||||
return projectPathMacroManager
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadStorageFile(xmlFile: Path, pathMacroManager: PathMacroManager): Map<String, Element> {
|
||||
val rootElement = JDOMUtil.load(xmlFile)
|
||||
if (Strings.endsWith(xmlFile.toString(), ".iml")) {
|
||||
if (xmlFile.toString().endsWith(".iml")) {
|
||||
DefaultImlNormalizer.normalize(rootElement)
|
||||
}
|
||||
return ComponentStorageUtil.loadComponents(rootElement, pathMacroManager)
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import org.jetbrains.annotations.ApiStatus
|
||||
* Project level extension point.
|
||||
*
|
||||
* Allows setting custom storage class using providing custom storage specs.
|
||||
* Or set custom stream provider for default storage (XmlElementStorage).
|
||||
* Or set a custom stream provider for default storage (XmlElementStorage).
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
interface StreamProviderFactory {
|
||||
|
||||
+12
-8
@@ -59,23 +59,27 @@ object JpsProjectEntitiesLoader {
|
||||
orphanage: MutableEntityStorage,
|
||||
errorReporter: ErrorReporter,
|
||||
context: SerializationContext) {
|
||||
val reader = context.fileContentReader
|
||||
val serializer = ModuleListSerializerImpl.createModuleEntitiesSerializer(moduleFile.toVirtualFileUrl(context.virtualFileUrlManager),
|
||||
null, source, context)
|
||||
val newEntities = serializer.loadEntities(reader, errorReporter, context.virtualFileUrlManager)
|
||||
val serializer = ModuleListSerializerImpl.createModuleEntitiesSerializer(
|
||||
fileUrl = moduleFile.toVirtualFileUrl(context.virtualFileUrlManager),
|
||||
moduleGroup = null,
|
||||
source = source,
|
||||
context = context,
|
||||
)
|
||||
val newEntities = serializer.loadEntities(context.fileContentReader, errorReporter, context.virtualFileUrlManager)
|
||||
serializer.checkAndAddToBuilder(builder, orphanage, newEntities.data)
|
||||
newEntities.exception?.let { throw it }
|
||||
}
|
||||
|
||||
fun createProjectSerializers(configLocation: JpsProjectConfigLocation,
|
||||
externalStoragePath: Path,
|
||||
context: SerializationContext): JpsProjectSerializers {
|
||||
fun createProjectSerializers(
|
||||
configLocation: JpsProjectConfigLocation,
|
||||
externalStoragePath: Path,
|
||||
context: SerializationContext,
|
||||
): JpsProjectSerializers {
|
||||
val externalStorageRoot = externalStoragePath.toVirtualFileUrl(context.virtualFileUrlManager)
|
||||
val externalStorageMapping = JpsExternalStorageMappingImpl(externalStorageRoot, configLocation)
|
||||
return when (configLocation) {
|
||||
is JpsProjectConfigLocation.FileBased -> createIprProjectSerializers(configLocation, externalStorageMapping, context)
|
||||
is JpsProjectConfigLocation.DirectoryBased -> createDirectoryProjectSerializers(configLocation, externalStorageMapping, context)
|
||||
else -> error("Unexpected state")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+21
-19
@@ -6,6 +6,7 @@ import com.intellij.openapi.application.WriteIntentReadAction
|
||||
import com.intellij.openapi.application.edtWriteAction
|
||||
import com.intellij.openapi.components.Service
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.components.serviceAsync
|
||||
import com.intellij.openapi.diagnostic.ControlFlowException
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.extensions.ExtensionPointName
|
||||
@@ -57,7 +58,7 @@ import java.nio.file.Path
|
||||
import java.util.function.Function
|
||||
import kotlin.coroutines.cancellation.CancellationException
|
||||
|
||||
internal val AFTER_IMPORT_CONFIGURATOR_EP: ExtensionPointName<MavenAfterImportConfigurator> = ExtensionPointName.create(
|
||||
internal val AFTER_IMPORT_CONFIGURATOR_EP: ExtensionPointName<MavenAfterImportConfigurator> = ExtensionPointName(
|
||||
"org.jetbrains.idea.maven.importing.afterImportConfigurator")
|
||||
|
||||
@TestOnly
|
||||
@@ -83,13 +84,15 @@ internal open class WorkspaceProjectImporter(
|
||||
|
||||
val migratedToExternalStorage = migrateToExternalStorageIfNeeded()
|
||||
|
||||
val storageBeforeImport = WorkspaceModel.getInstance(myProject).currentSnapshot
|
||||
val storageBeforeImport = myProject.serviceAsync<WorkspaceModel>().currentSnapshot
|
||||
|
||||
val projectChangesInfo = tracer.spanBuilder("collectProjectChanges").use {
|
||||
collectProjectChanges(storageBeforeImport, projectsToImport, migratedToExternalStorage)
|
||||
}
|
||||
|
||||
if (!projectChangesInfo.hasChanges) return emptyList()
|
||||
if (!projectChangesInfo.hasChanges) {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
val postTasks = ArrayList<MavenProjectsProcessorTask>()
|
||||
val stats = WorkspaceImportStats.start(myProject)
|
||||
@@ -144,24 +147,23 @@ internal open class WorkspaceProjectImporter(
|
||||
}
|
||||
|
||||
private fun migrateToExternalStorageIfNeeded(): Boolean {
|
||||
var migratedToExternalStorage = false
|
||||
val externalStorageManager = ExternalStorageConfigurationManager.getInstance(myProject)
|
||||
if (!externalStorageManager.isEnabled) {
|
||||
ExternalProjectsManagerImpl.getInstance(myProject).setStoreExternally(true)
|
||||
migratedToExternalStorage = true
|
||||
|
||||
if (!externalStorageManager.isEnabled) {
|
||||
MavenLog.LOG.error(
|
||||
"Can't migrate the project to external project files storage: ExternalStorageConfigurationManager.isEnabled=false")
|
||||
}
|
||||
else if (!myProject.isExternalStorageEnabled) {
|
||||
MavenLog.LOG.warn("Can't migrate the project to external project files storage: Project.isExternalStorageEnabled=false")
|
||||
}
|
||||
else {
|
||||
MavenLog.LOG.info("Project has been migrated to external project files storage")
|
||||
}
|
||||
if (externalStorageManager.isEnabled) {
|
||||
return false
|
||||
}
|
||||
return migratedToExternalStorage
|
||||
|
||||
ExternalProjectsManagerImpl.getInstance(myProject).setStoreExternally(true)
|
||||
|
||||
if (!externalStorageManager.isEnabled) {
|
||||
MavenLog.LOG.error("Can't migrate the project to external project files storage: ExternalStorageConfigurationManager.isEnabled=false")
|
||||
}
|
||||
else if (!myProject.isExternalStorageEnabled) {
|
||||
MavenLog.LOG.warn("Can't migrate the project to external project files storage: Project.isExternalStorageEnabled=false")
|
||||
}
|
||||
else {
|
||||
MavenLog.LOG.info("Project has been migrated to external project files storage")
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private data class ProjectChangesInfo(val hasChanges: Boolean, val allProjectsToChanges: Map<MavenProject, MavenProjectModifications>) {
|
||||
|
||||
Reference in New Issue
Block a user