cleanup - extract cwmLayout.kt

GitOrigin-RevId: 75fb868f3bb7e159cf9fe3da5b828975f3991b7e
This commit is contained in:
Vladimir Krivosheev
2024-02-07 17:02:46 +00:00
committed by intellij-monorepo-bot
parent baa9430172
commit 6283819c6c
2 changed files with 11 additions and 14 deletions
@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.jps.model.serialization;
import com.intellij.openapi.diagnostic.Logger;
@@ -28,8 +28,7 @@ public abstract class JpsLoaderBase {
/**
* Returns null if file doesn't exist
*/
@Nullable
protected Element loadRootElement(@NotNull Path file) {
protected @Nullable Element loadRootElement(@NotNull Path file) {
return loadRootElement(file, myMacroExpander);
}
@@ -50,16 +49,14 @@ public abstract class JpsLoaderBase {
timingLog.run();
}
@Nullable
protected <E extends JpsElement> Element loadComponentData(@NotNull JpsElementExtensionSerializerBase<E> serializer, @NotNull Path configFile) {
protected @Nullable <E extends JpsElement> Element loadComponentData(@NotNull JpsElementExtensionSerializerBase<E> serializer, @NotNull Path configFile) {
return JDomSerializationUtil.findComponent(loadRootElement(configFile), serializer.getComponentName());
}
/**
* Returns null if file doesn't exist
*/
@Nullable
protected static Element loadRootElement(@NotNull Path file, @NotNull JpsMacroExpander macroExpander) {
protected static @Nullable Element loadRootElement(@NotNull Path file, @NotNull JpsMacroExpander macroExpander) {
final Element element = tryLoadRootElement(file);
if (element != null) {
macroExpander.substitute(element, SystemInfo.isFileSystemCaseSensitive);
@@ -67,8 +64,7 @@ public abstract class JpsLoaderBase {
return element;
}
@Nullable
public static Element tryLoadRootElement(@NotNull Path file) {
public static @Nullable Element tryLoadRootElement(@NotNull Path file) {
int i = 0;
while (true) {
try {
@@ -91,7 +87,7 @@ public abstract class JpsLoaderBase {
}
}
//most likely configuration file is being written by IDE so we'll wait a little
// the most likely configuration file is being written by IDE, so we'll wait a little
try {
//noinspection BusyWait
Thread.sleep(300);
@@ -41,10 +41,11 @@ import org.jetbrains.jps.model.library.sdk.JpsSdkReference
import org.jetbrains.jps.model.module.JpsModule
import org.jetbrains.jps.model.serialization.JpsModelSerializationDataService
import org.jetbrains.jps.model.serialization.JpsPathMapper
import org.jetbrains.jps.model.serialization.JpsProjectLoader.loadProject
import org.jetbrains.jps.model.serialization.JpsProjectLoader
import org.jetbrains.jps.util.JpsPathUtil
import java.nio.file.Files
import java.nio.file.Path
import kotlin.io.path.invariantSeparatorsPathString
import kotlin.io.path.relativeToOrNull
@Obsolete
@@ -371,10 +372,10 @@ private suspend fun loadProject(projectHome: Path, kotlinBinaries: KotlinBinarie
withContext(Dispatchers.IO) {
spanBuilder("load project").useWithScope { span ->
pathVariablesConfiguration.addPathVariable("MAVEN_REPOSITORY", FileUtilRt.toSystemIndependentName(
Path.of(SystemProperties.getUserHome(), ".m2/repository").toString()))
pathVariablesConfiguration.addPathVariable("MAVEN_REPOSITORY",
Path.of(SystemProperties.getUserHome(), ".m2/repository").invariantSeparatorsPathString)
val pathVariables = JpsModelSerializationDataService.computeAllPathVariables(model.global)
loadProject(model.project, pathVariables, JpsPathMapper.IDENTITY, projectHome, { launch { it.run() } }, false)
JpsProjectLoader.loadProject(model.project, pathVariables, JpsPathMapper.IDENTITY, projectHome, { launch { it.run() } }, false)
span.setAllAttributes(Attributes.of(
AttributeKey.stringKey("project"), projectHome.toString(),
AttributeKey.longKey("moduleCount"), model.project.modules.size.toLong(),