From 9818f02bc04df0e3ba6f4d35c1dd8ebc549a73f8 Mon Sep 17 00:00:00 2001 From: Oleksandr Liemiahov Date: Wed, 18 Nov 2026 18:37:11 +0100 Subject: [PATCH 1/2] Keep unresolved children in content: instead of skipping the save A child listed in a container's `content:` that could not be resolved on load (its directory was deleted, its config was missing or broken) made the container "partially loaded", and YamlFormatSynchronizer.saveItem then skipped every save of its config for the rest of the session. Every child added later never reached `content:` and vanished after the next restart. For Hyperskill this lost each topic opened after a single topic folder had gone missing: the folders stayed on disk, but the topics disappeared from the course, and reopening one from the browser created " (1)". Now the container remembers the unresolved entries together with the resolved entry each one followed (ItemContainer.unresolvedContent), and the YAML mixins write `content:` from ItemContainer.contentNames, which puts them back in place. The container is saved as usual, so the on-disk list keeps the unresolved names and still gains new children. Adding a child with the same name takes the entry over. The loader now logs which child it could not resolve. --- .../learning/courseFormat/ItemContainer.kt | 52 +++++++ .../learning/courseFormat/StudyItem.kt | 16 --- .../learning/yaml/format/CourseYamlUtil.kt | 10 +- .../learning/yaml/format/LessonYamlUtil.kt | 11 +- .../learning/yaml/format/SectionYamlUtil.kt | 11 +- .../yaml/format/StudyItemConverter.kt | 9 -- .../academy/learning/EduProjectActivity.kt | 6 +- .../learning/yaml/YamlFormatSynchronizer.kt | 19 +-- .../academy/learning/yaml/YamlLoader.kt | 19 ++- .../yaml/format/StudyItemChangeApplier.kt | 17 +-- .../yaml/UnresolvedContentYamlTest.kt | 128 ++++++++++++++++++ 11 files changed, 220 insertions(+), 78 deletions(-) delete mode 100644 hs-edu-format/src/org/hyperskill/academy/learning/yaml/format/StudyItemConverter.kt create mode 100644 intellij-plugin/hs-core/testSrc/org/hyperskill/academy/learning/yaml/UnresolvedContentYamlTest.kt diff --git a/hs-edu-format/src/org/hyperskill/academy/learning/courseFormat/ItemContainer.kt b/hs-edu-format/src/org/hyperskill/academy/learning/courseFormat/ItemContainer.kt index f12cdfc94..bad56a196 100644 --- a/hs-edu-format/src/org/hyperskill/academy/learning/courseFormat/ItemContainer.kt +++ b/hs-edu-format/src/org/hyperskill/academy/learning/courseFormat/ItemContainer.kt @@ -8,6 +8,43 @@ abstract class ItemContainer : StudyItem() { } private var _items = mutableListOf() + + /** + * Entries of this container's `content:` list that could not be resolved during the last load: the child directory or + * its config file was missing, or the config failed to deserialize. They are not part of [items], but [contentNames] + * still writes them back, so saving the container neither drops them from the config file on disk nor has to be + * skipped -- a container that refused to save would silently lose every child added to it later. + * + * Recomputed on every load, so a later complete load clears it again. + */ + @Transient + var unresolvedContent: List = emptyList() + + /** + * The `content:` list of this container's config file: the names of [items] in their order, with each + * [unresolvedContent] entry kept right after the entry it followed on disk. + */ + val contentNames: List + get() { + val names = items.map { it.name } + if (unresolvedContent.isEmpty()) return names + + val present = names.toSet() + val (anchored, orphaned) = unresolvedContent + .filter { it.name !in present } + .partition { it.previousName == null || it.previousName in present } + val namesByAnchor = anchored.groupBy({ it.previousName }, { it.name }) + return buildList { + addAll(namesByAnchor[null].orEmpty()) + for (name in names) { + add(name) + addAll(namesByAnchor[name].orEmpty()) + } + // The entry they followed is gone from the container, so there is no position left to keep. + addAll(orphaned.map { it.name }) + } + } + override fun init(parentItem: ItemContainer, isRestarted: Boolean) { parent = parentItem for ((i, item) in items.withIndex()) { @@ -30,11 +67,20 @@ abstract class ItemContainer : StudyItem() { fun addItem(item: StudyItem) { _items.add(item) item.parent = this + forgetUnresolved(item.name) } fun addItem(index: Int, item: StudyItem) { _items.add(index, item) item.parent = this + forgetUnresolved(item.name) + } + + // From now on the item owns this name, so removing it later must not bring the unresolved entry back. + private fun forgetUnresolved(name: String) { + if (unresolvedContent.any { it.name == name }) { + unresolvedContent = unresolvedContent.filter { it.name != name } + } } fun replaceItem(existingItem: StudyItem, newItem: StudyItem) { @@ -52,3 +98,9 @@ abstract class ItemContainer : StudyItem() { _items.sortBy { it.index } } } + +/** + * A `content:` entry named [name] that could not be resolved during load. [previousName] is the closest resolved entry + * before it (`null` if there is none), so [ItemContainer.contentNames] can write it back at the same place. + */ +data class UnresolvedContentEntry(val name: String, val previousName: String?) diff --git a/hs-edu-format/src/org/hyperskill/academy/learning/courseFormat/StudyItem.kt b/hs-edu-format/src/org/hyperskill/academy/learning/courseFormat/StudyItem.kt index e8fbcf141..0715f2dde 100644 --- a/hs-edu-format/src/org/hyperskill/academy/learning/courseFormat/StudyItem.kt +++ b/hs-edu-format/src/org/hyperskill/academy/learning/courseFormat/StudyItem.kt @@ -23,22 +23,6 @@ abstract class StudyItem() { var id: Int = 0 // id on remote resource (Stepik, Marketplace) var contentTags: List = listOf() - /** - * `true` when this item's children could not be fully resolved during the last load: a child directory or its config - * file was missing, or a child failed to deserialize. Such an item holds fewer children than the config file on disk - * claims, so writing it back would persist the truncated `content:` list and permanently drop the missing children. - * - * [org.hyperskill.academy.learning.yaml.YamlFormatSynchronizer.saveItem] refuses to write the *structural* config - * while this is set; the remote config keeps being written, as it holds no `content:` list. - * It is recomputed on every load rather than latched, so a later complete load clears it again. - * - * Note this covers children only. A [org.hyperskill.academy.learning.courseFormat.tasks.Task] whose task files - * could not be resolved is deliberately *not* marked here: its `status` lives in the same config file, so blocking - * the save would stop the solved state from being persisted. - */ - @Transient - var isPartiallyLoaded: Boolean = false - @Transient private var _parent: ItemContainer? = null diff --git a/hs-edu-format/src/org/hyperskill/academy/learning/yaml/format/CourseYamlUtil.kt b/hs-edu-format/src/org/hyperskill/academy/learning/yaml/format/CourseYamlUtil.kt index ed8fdb539..2f9ba9b95 100644 --- a/hs-edu-format/src/org/hyperskill/academy/learning/yaml/format/CourseYamlUtil.kt +++ b/hs-edu-format/src/org/hyperskill/academy/learning/yaml/format/CourseYamlUtil.kt @@ -105,10 +105,12 @@ abstract class CourseYamlMixin { @JsonInclude(JsonInclude.Include.NON_EMPTY) private lateinit var environment: String - @JsonSerialize(contentConverter = StudyItemConverter::class) - @JsonProperty(CONTENT) - @JsonInclude(JsonInclude.Include.NON_EMPTY) - private lateinit var _items: List + // Not the `items` themselves: the names also keep the entries that could not be resolved on load, + // see `ItemContainer.unresolvedContent` + val contentNames: List + @JsonProperty(CONTENT) + @JsonInclude(JsonInclude.Include.NON_EMPTY) + get() = throw NotImplementedInMixin() @JsonProperty(SOLUTIONS_HIDDEN) @JsonInclude(JsonInclude.Include.NON_DEFAULT) diff --git a/hs-edu-format/src/org/hyperskill/academy/learning/yaml/format/LessonYamlUtil.kt b/hs-edu-format/src/org/hyperskill/academy/learning/yaml/format/LessonYamlUtil.kt index b64c8c61d..ea1aadfe3 100644 --- a/hs-edu-format/src/org/hyperskill/academy/learning/yaml/format/LessonYamlUtil.kt +++ b/hs-edu-format/src/org/hyperskill/academy/learning/yaml/format/LessonYamlUtil.kt @@ -8,9 +8,8 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.annotation.JsonPropertyOrder import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder -import com.fasterxml.jackson.databind.annotation.JsonSerialize import org.hyperskill.academy.learning.courseFormat.Lesson -import org.hyperskill.academy.learning.courseFormat.StudyItem +import org.hyperskill.academy.learning.json.mixins.NotImplementedInMixin import org.hyperskill.academy.learning.yaml.errorHandling.formatError import org.hyperskill.academy.learning.yaml.errorHandling.unnamedItemAtMessage import org.hyperskill.academy.learning.yaml.format.YamlMixinNames.CONTENT @@ -29,9 +28,11 @@ abstract class LessonYamlMixin { @JsonInclude(JsonInclude.Include.NON_NULL) private var customPresentableName: String? = null - @JsonProperty(CONTENT) - @JsonSerialize(contentConverter = StudyItemConverter::class) - private lateinit var _items: List + // Not the `items` themselves: the names also keep the entries that could not be resolved on load, + // see `ItemContainer.unresolvedContent` + val contentNames: List + @JsonProperty(CONTENT) + get() = throw NotImplementedInMixin() @JsonProperty(TAGS) @JsonInclude(JsonInclude.Include.NON_EMPTY) diff --git a/hs-edu-format/src/org/hyperskill/academy/learning/yaml/format/SectionYamlUtil.kt b/hs-edu-format/src/org/hyperskill/academy/learning/yaml/format/SectionYamlUtil.kt index 0200c4e41..23a277457 100644 --- a/hs-edu-format/src/org/hyperskill/academy/learning/yaml/format/SectionYamlUtil.kt +++ b/hs-edu-format/src/org/hyperskill/academy/learning/yaml/format/SectionYamlUtil.kt @@ -7,9 +7,8 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.annotation.JsonPropertyOrder import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder -import com.fasterxml.jackson.databind.annotation.JsonSerialize import org.hyperskill.academy.learning.courseFormat.Section -import org.hyperskill.academy.learning.courseFormat.StudyItem +import org.hyperskill.academy.learning.json.mixins.NotImplementedInMixin import org.hyperskill.academy.learning.yaml.errorHandling.formatError import org.hyperskill.academy.learning.yaml.errorHandling.unnamedItemAtMessage import org.hyperskill.academy.learning.yaml.format.YamlMixinNames.CONTENT @@ -28,9 +27,11 @@ abstract class SectionYamlMixin { @JsonInclude(JsonInclude.Include.NON_NULL) private var customPresentableName: String? = null - @JsonProperty(CONTENT) - @JsonSerialize(contentConverter = StudyItemConverter::class) - private lateinit var _items: List + // Not the `items` themselves: the names also keep the entries that could not be resolved on load, + // see `ItemContainer.unresolvedContent` + val contentNames: List + @JsonProperty(CONTENT) + get() = throw NotImplementedInMixin() @JsonProperty(TAGS) @JsonInclude(JsonInclude.Include.NON_EMPTY) diff --git a/hs-edu-format/src/org/hyperskill/academy/learning/yaml/format/StudyItemConverter.kt b/hs-edu-format/src/org/hyperskill/academy/learning/yaml/format/StudyItemConverter.kt deleted file mode 100644 index 578adba5f..000000000 --- a/hs-edu-format/src/org/hyperskill/academy/learning/yaml/format/StudyItemConverter.kt +++ /dev/null @@ -1,9 +0,0 @@ -package org.hyperskill.academy.learning.yaml.format - -import com.fasterxml.jackson.databind.util.StdConverter -import org.hyperskill.academy.learning.courseFormat.StudyItem - - -class StudyItemConverter : StdConverter() { - override fun convert(item: StudyItem): String = item.name -} \ No newline at end of file diff --git a/intellij-plugin/hs-core/src/org/hyperskill/academy/learning/EduProjectActivity.kt b/intellij-plugin/hs-core/src/org/hyperskill/academy/learning/EduProjectActivity.kt index cf0277213..0ca819645 100644 --- a/intellij-plugin/hs-core/src/org/hyperskill/academy/learning/EduProjectActivity.kt +++ b/intellij-plugin/hs-core/src/org/hyperskill/academy/learning/EduProjectActivity.kt @@ -95,9 +95,9 @@ class EduProjectActivity : ProjectActivity { @RequiresBlockingContext fun migrateYaml(project: Project, course: Course) { // `saveAll` rewrites every config file from the in-memory model. If that model resolved only partially - // (see `YamlLoader.deserializeContent` and `YamlDeepLoader.removeNonExistingTaskFiles`, both of which silently - // drop unresolvable children), running it on every project open turns a transient loading problem into permanent - // data loss on disk. Save only when a migration actually ran: the YAML-format migration in + // (see `YamlDeepLoader.removeNonExistingTaskFiles`, which silently drops unresolvable task files), running it on + // every project open turns a transient loading problem into permanent data loss on disk. Save only when a + // migration actually ran: the YAML-format migration in // `YamlDeepLoader.loadCourse` already has its own `needMigration`-gated `saveAll`. if (!migrateCanCheckLocallyYaml(project, course)) return YamlFormatSynchronizer.saveAll(project) diff --git a/intellij-plugin/hs-core/src/org/hyperskill/academy/learning/yaml/YamlFormatSynchronizer.kt b/intellij-plugin/hs-core/src/org/hyperskill/academy/learning/yaml/YamlFormatSynchronizer.kt index fd51ea7f8..86bd8bcf8 100644 --- a/intellij-plugin/hs-core/src/org/hyperskill/academy/learning/yaml/YamlFormatSynchronizer.kt +++ b/intellij-plugin/hs-core/src/org/hyperskill/academy/learning/yaml/YamlFormatSynchronizer.kt @@ -3,7 +3,6 @@ package org.hyperskill.academy.learning.yaml import com.fasterxml.jackson.databind.ObjectMapper import com.intellij.openapi.application.runReadAction import com.intellij.openapi.application.runWriteAction -import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.EditorFactory import com.intellij.openapi.fileEditor.FileDocumentManager @@ -53,8 +52,6 @@ import javax.swing.JLabel import javax.swing.JPanel object YamlFormatSynchronizer { - private val LOG = Logger.getInstance(YamlFormatSynchronizer::class.java) - val LOAD_FROM_CONFIG = Key("Hyperskill.loadItem") val SAVE_TO_CONFIG = Key("Hyperskill.saveItem") private val SYNCHRONIZATION_STARTED = Key("Hyperskill.synchronizationStarted") @@ -90,18 +87,10 @@ object YamlFormatSynchronizer { if (!YamlFormatSettings.shouldCreateConfigFiles(project)) { return } - // The item holds fewer children than its config file on disk claims, because some of them could not be resolved - // during the last load. Writing it out now would persist the truncated `content:` list and permanently drop the - // missing children from the course. Skipping the save keeps the on-disk structure intact until a load succeeds. - // - // Only the structural config is guarded. `*-remote-info.yaml` carries no `content:` list, so a partially loaded - // item has to keep persisting its remote state (id, update date, submissions) as usual -- otherwise a single - // unresolvable child would silently freeze the remote state of its whole container for the rest of the session. - if (item.isPartiallyLoaded && configName == item.configFileName) { - LOG.warn("Skipping save of ${item.itemType} `${item.name}`: its children were not fully resolved during load") - return - } - + // A container whose children were not all resolved during the last load is saved like any other: its `content:` + // keeps the unresolved names (see `ItemContainer.unresolvedContent`), so the save neither drops them nor has to be + // skipped. Skipping it lost every child added later, e.g. each Hyperskill topic opened after one topic folder + // went missing. item.saveConfig(project, configName, mapper) } diff --git a/intellij-plugin/hs-core/src/org/hyperskill/academy/learning/yaml/YamlLoader.kt b/intellij-plugin/hs-core/src/org/hyperskill/academy/learning/yaml/YamlLoader.kt index 445f20a38..5ac9d73bb 100644 --- a/intellij-plugin/hs-core/src/org/hyperskill/academy/learning/yaml/YamlLoader.kt +++ b/intellij-plugin/hs-core/src/org/hyperskill/academy/learning/yaml/YamlLoader.kt @@ -114,27 +114,26 @@ object YamlLoader { } } - internal inline fun StudyItem.deserializeContent( + internal inline fun ItemContainer.deserializeContent( project: Project, contentList: List, mapper: ObjectMapper = basicMapper(), ): List { val content = mutableListOf() - var unresolvedChildren = false + val unresolved = mutableListOf() for (titledItem in contentList) { val configFile: VirtualFile? = getConfigFileForChild(project, titledItem.name) - if (configFile == null) { - unresolvedChildren = true - continue + val deserializeItem = configFile?.let { + deserializeItemProcessingErrors(it, project, mapper = mapper, parentItem = this) as? T } - val deserializeItem = deserializeItemProcessingErrors(configFile, project, mapper = mapper, parentItem = this) as? T - if (deserializeItem == null) { - unresolvedChildren = true + if (configFile == null || deserializeItem == null) { + LOG.warn("Cannot resolve `${titledItem.name}` listed in the content of $itemType `$name`, keeping it in the config") + unresolved += UnresolvedContentEntry(titledItem.name, content.lastOrNull()?.name) continue } if (this is Lesson && isHyperskillTopicsLesson() && deserializeItem is UnsupportedTask) { // A deliberate skip, not an unresolved child: topic lessons legitimately contain tasks this IDE cannot - // support, so this must not mark the lesson partially loaded and block saving it. + // support, so the next save drops them from the lesson config. LOG.warn( "Skipping unsupported task `${titledItem.name}` while loading Hyperskill topic lesson `${name}` from ${configFile.path}" ) @@ -146,7 +145,7 @@ object YamlLoader { } // Recomputed on every load rather than latched, so a later complete load clears it again. - isPartiallyLoaded = unresolvedChildren + unresolvedContent = unresolved return content } diff --git a/intellij-plugin/hs-core/src/org/hyperskill/academy/learning/yaml/format/StudyItemChangeApplier.kt b/intellij-plugin/hs-core/src/org/hyperskill/academy/learning/yaml/format/StudyItemChangeApplier.kt index 9cdc27fcd..30c1e712d 100644 --- a/intellij-plugin/hs-core/src/org/hyperskill/academy/learning/yaml/format/StudyItemChangeApplier.kt +++ b/intellij-plugin/hs-core/src/org/hyperskill/academy/learning/yaml/format/StudyItemChangeApplier.kt @@ -68,7 +68,7 @@ open class ItemContainerChangeApplier(val project: Project) : val existingChildren = existingItem.items val preservedChildren = mutableListOf() val mapper = mapper() - var unresolvedChildren = false + val unresolved = mutableListOf() for (titledItem in deserializedItem.items) { val child = existingChildren.find { it.name == titledItem.name } if (child != null) { @@ -79,14 +79,9 @@ open class ItemContainerChangeApplier(val project: Project) : // this code adding new child item if it was added in config and there's a dir // it is called from `YamlLoader.loadItem` val configFile = existingItem.getConfigFileForChild(project, titledItem.name) - if (configFile == null) { - unresolvedChildren = true - continue - } - - val deserializedChild = deserializeItemProcessingErrors(configFile, project, mapper = mapper) + val deserializedChild = configFile?.let { deserializeItemProcessingErrors(it, project, mapper = mapper) } if (deserializedChild == null) { - unresolvedChildren = true + unresolved += UnresolvedContentEntry(titledItem.name, preservedChildren.lastOrNull()?.name) continue } deserializedChild.name = titledItem.name @@ -98,9 +93,9 @@ open class ItemContainerChangeApplier(val project: Project) : } // update items so as removed items are no longer in the course existingItem.items = preservedChildren - // A child named in the config could not be resolved, so `preservedChildren` is shorter than what the config file - // on disk claims. Recomputed on every apply rather than latched, so a later complete load clears it again. - existingItem.isPartiallyLoaded = unresolvedChildren + // Children named in the config that could not be resolved stay in it on the next save. + // Recomputed on every apply rather than latched, so a later complete load clears it again. + existingItem.unresolvedContent = unresolved existingItem.init(existingItem.parent, false) } } diff --git a/intellij-plugin/hs-core/testSrc/org/hyperskill/academy/learning/yaml/UnresolvedContentYamlTest.kt b/intellij-plugin/hs-core/testSrc/org/hyperskill/academy/learning/yaml/UnresolvedContentYamlTest.kt new file mode 100644 index 000000000..5254c6449 --- /dev/null +++ b/intellij-plugin/hs-core/testSrc/org/hyperskill/academy/learning/yaml/UnresolvedContentYamlTest.kt @@ -0,0 +1,128 @@ +package org.hyperskill.academy.learning.yaml + +import com.intellij.openapi.application.runWriteAction +import com.intellij.openapi.vfs.VfsUtil +import com.intellij.util.ui.UIUtil +import org.hyperskill.academy.coursecreator.yaml.createConfigFiles +import org.hyperskill.academy.learning.StudyTaskManager +import org.hyperskill.academy.learning.courseDir +import org.hyperskill.academy.learning.courseFormat.* +import org.hyperskill.academy.learning.courseFormat.ext.getDir +import org.hyperskill.academy.learning.courseFormat.tasks.EduTask +import org.hyperskill.academy.learning.courseGeneration.GeneratorUtils +import org.hyperskill.academy.learning.yaml.YamlConfigSettings.configFileName +import org.junit.Test + +/** + * A child listed in a container's `content:` that cannot be resolved on load (its directory was deleted, its config + * is broken) must neither be dropped from the config file nor stop the container from being saved. + */ +class UnresolvedContentYamlTest : YamlTestCase() { + + @Test + fun `test lesson added to a partially loaded section survives reload`() { + createSectionWithLessons("lesson1", "lesson2", "lesson3") + deleteCourseDir("Topics/lesson2") + + val section = reloadSection() + assertEquals(listOf("lesson1", "lesson3"), section.items.map { it.name }) + assertEquals(listOf(UnresolvedContentEntry("lesson2", "lesson1")), section.unresolvedContent) + + addLessonAndSave(section, "lesson4") + + assertEquals(listOf("lesson1", "lesson2", "lesson3", "lesson4"), contentOnDisk(section)) + assertEquals(listOf("lesson1", "lesson3", "lesson4"), reloadSection().items.map { it.name }) + } + + @Test + fun `test complete load clears unresolved content`() { + createSectionWithLessons("lesson1", "lesson2") + val lessonConfig = project.courseDir.findFileByRelativePath("Topics/lesson2/${YamlConfigSettings.LESSON_CONFIG}")!! + val lessonConfigText = VfsUtil.loadText(lessonConfig) + runWriteAction { lessonConfig.delete(this) } + + assertEquals(listOf("lesson2"), reloadSection().unresolvedContent.map { it.name }) + + runWriteAction { + val lessonDir = project.courseDir.findFileByRelativePath("Topics/lesson2")!! + VfsUtil.saveText(lessonDir.createChildData(this, YamlConfigSettings.LESSON_CONFIG), lessonConfigText) + } + + val section = reloadSection() + assertEquals(listOf("lesson1", "lesson2"), section.items.map { it.name }) + assertEmpty(section.unresolvedContent) + } + + @Test + fun `test re-created child replaces its unresolved entry`() { + createSectionWithLessons("lesson1", "lesson2", "lesson3") + deleteCourseDir("Topics/lesson2") + val section = reloadSection() + + addLessonAndSave(section, "lesson2") + + assertEmpty(section.unresolvedContent) + assertEquals(listOf("lesson1", "lesson3", "lesson2"), contentOnDisk(section)) + } + + @Test + fun `test unresolved entries are written back where they were`() { + val section = Section() + section.items = listOf("a", "c").map { Lesson().apply { name = it } } + section.unresolvedContent = listOf( + UnresolvedContentEntry("first", null), + UnresolvedContentEntry("b1", "a"), + UnresolvedContentEntry("b2", "a"), + UnresolvedContentEntry("orphan", "removed"), + UnresolvedContentEntry("c", "a"), + ) + + // `c` is present again, and `orphan` lost the entry it followed, so it goes last + assertEquals(listOf("first", "a", "b1", "b2", "c", "orphan"), section.contentNames) + } + + private fun createSectionWithLessons(vararg lessonNames: String) { + courseWithFiles { + section("Topics") { + for (lessonName in lessonNames) { + lesson(lessonName) { + eduTask("task1") { + taskFile("Task.txt") + } + } + } + } + } + createConfigFiles(project) + } + + private fun deleteCourseDir(path: String) { + runWriteAction { project.courseDir.findFileByRelativePath(path)!!.delete(this) } + } + + private fun reloadSection(): Section { + val course = YamlDeepLoader.loadCourse(project)!! + StudyTaskManager.getInstance(project).course = course + return course.getItem("Topics") as Section + } + + // The same steps as `HyperskillOpenInIdeRequestHandler` takes to add a topic opened from the browser + private fun addLessonAndSave(section: Section, lessonName: String) { + val lesson = Lesson() + lesson.name = lessonName + lesson.addTask(EduTask("task1")) + section.addLesson(lesson) + section.init(section.course, false) + + GeneratorUtils.createLesson(project, lesson, section.getDir(project.courseDir)!!) + lesson.taskList.forEach { YamlFormatSynchronizer.saveItem(it) } + YamlFormatSynchronizer.saveItem(lesson) + YamlFormatSynchronizer.saveItem(section) + UIUtil.dispatchAllInvocationEvents() + } + + private fun contentOnDisk(item: StudyItem): List { + val configFile = item.getConfigDir(project)!!.findChild(item.configFileName)!! + return YamlMapper.basicMapper().readTree(VfsUtil.loadText(configFile))["content"].map { it.asText() } + } +} From 994c583a4b3575d8df799f9696e4dd141a70180d Mon Sep 17 00:00:00 2001 From: Oleksandr Liemiahov Date: Wed, 18 Nov 2026 10:51:27 +0100 Subject: [PATCH 2/2] Remove the dead JetBrains Space Maven repository maven.pkg.jetbrains.space no longer resolves: JetBrains Space package hosting is shut down. Gradle asks repositories in declaration order, and this one came before the IntelliJ Platform and Marketplace repositories, so every artifact that was not cached yet failed on it instead of falling through to the next repository. The new Rust plugin build for 263 (263.7307.313) broke `:intellij-plugin:hs-Rust:compileKotlin` this way, and any build against a new IDE version would too. The only artifact taken from it, kotlin-css-jvm 2026.8.4, is on Maven Central. (cherry picked from commit 53c5a41218d4486e1ddb6a69e7b5c4efdb45847d) --- buildSrc/src/main/kotlin/common-conventions.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/common-conventions.gradle.kts b/buildSrc/src/main/kotlin/common-conventions.gradle.kts index f668325d3..2f389b31c 100644 --- a/buildSrc/src/main/kotlin/common-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/common-conventions.gradle.kts @@ -41,7 +41,6 @@ kotlin { repositories { mavenCentral() maven("https://cache-redirector.jetbrains.com/intellij-dependencies") - maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-js-wrappers") maven("https://packages.jetbrains.team/maven/p/edu/maven") maven("https://packages.jetbrains.team/maven/p/edu/educational-ml-library") maven("https://packages.jetbrains.team/maven/p/grazi/grazie-platform-public")