Skip to content

Commit ebaacd9

Browse files
authored
ALT-10982
* ALT-10982 read lock acquisition moved inside getFormattedTaskText * ALT-10982, ALT-10988 inner directory access fixed * ALT-10991 only theory/code tasks can be solved at this point of time * ALT-10982, ALT-10991 plugin version updated
1 parent 4719e3c commit ebaacd9

6 files changed

Lines changed: 28 additions & 26 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# supported values: 252, 253
22
environmentName=253
33

4-
pluginVersion=2026.3
4+
pluginVersion=2026.6
55

66
# type of IDE (IDEA, CLion, etc.) used to build/test running
77
# for more details see `Different IDEs` section in `PlatformVersions.md`

intellij-plugin/hs-core/src/org/hyperskill/academy/coursecreator/validation/CourseValidationHelper.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ class CourseValidationHelper(
9595
}
9696

9797
private suspend fun TestSuiteBuilder.validateTaskDescriptionLinks(project: Project, task: Task) {
98-
val text = readAction { task.getFormattedTaskText(project) } ?: return
98+
val text = task.getFormattedTaskText(project)
99+
?: return
99100
val links = extractLinks(project, task, text)
100101
// Don't create empty node if no links in the task description
101102
if (links.isEmpty()) return

intellij-plugin/hs-core/src/org/hyperskill/academy/learning/courseFormat/ext/StudyItemExt.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ fun StudyItem.getDir(courseDir: VirtualFile): VirtualFile? {
3030
lessonParent.getDir(courseDir)?.findFileByRelativePath(lessonParent.getPathToChildren())?.findChild(name)
3131
}
3232

33-
is Task -> (parentOrNull as? Lesson)?.getDir(courseDir)?.let { findDir(it) }
33+
is Task -> (parentOrNull as? Lesson)
34+
?.getDir(courseDir)
35+
?.findChild(targetDirName)
3436
else -> error("Can't find directory for the item $itemType")
3537
}
3638
}

intellij-plugin/hs-core/src/org/hyperskill/academy/learning/courseFormat/ext/TaskExt.kt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ import com.intellij.psi.PsiDirectory
1515
import com.intellij.psi.PsiFile
1616
import com.intellij.psi.PsiManager
1717
import com.intellij.psi.util.PsiUtilCore
18+
import com.intellij.util.SlowOperations
1819
import com.intellij.util.concurrency.annotations.RequiresReadLock
1920
import org.hyperskill.academy.learning.EduUtilsKt.convertToHtml
2021
import org.hyperskill.academy.learning.courseDir
2122
import org.hyperskill.academy.learning.courseFormat.*
2223
import org.hyperskill.academy.learning.courseFormat.EduFormatNames.TASK
2324
import org.hyperskill.academy.learning.courseFormat.hyperskill.HyperskillCourse
25+
import org.hyperskill.academy.learning.courseFormat.tasks.CodeTask
2426
import org.hyperskill.academy.learning.courseFormat.tasks.Task
2527
import org.hyperskill.academy.learning.courseFormat.tasks.TheoryTask
2628
import org.hyperskill.academy.learning.courseGeneration.GeneratorUtils
@@ -46,9 +48,13 @@ val Task.dirName: String
4648
return TASK
4749
}
4850

49-
fun Task.findDir(lessonDir: VirtualFile?): VirtualFile? {
50-
return lessonDir?.findChild(dirName)
51-
}
51+
val Task.targetDirName: String
52+
get() = when (this) {
53+
is TheoryTask,
54+
is CodeTask -> name
55+
56+
else -> dirName
57+
}
5258

5359
fun Task.findSourceDir(taskDir: VirtualFile): VirtualFile? {
5460
val sourceDir = sourceDir ?: return null
@@ -109,7 +115,7 @@ fun Task.getDescriptionFile(
109115
): VirtualFile? {
110116
val taskDirectory = getTaskDirectory(project) ?: return null
111117

112-
val file = com.intellij.util.SlowOperations.knownIssue("EDU-8086").use {
118+
val file = SlowOperations.knownIssue("EDU-8086").use {
113119
if (guessFormat) {
114120
taskDirectory.run { findChild(DescriptionFormat.HTML.fileName) ?: findChild(DescriptionFormat.MD.fileName) }
115121
}
@@ -186,9 +192,11 @@ private fun VirtualFile.toDescriptionFormat(): DescriptionFormat =
186192
DescriptionFormat.values().firstOrNull { it.extension == extension }
187193
?: loadingError(EduCoreBundle.message("yaml.editor.invalid.description"))
188194

189-
@RequiresReadLock
190195
fun Task.getFormattedTaskText(project: Project): String? {
191-
var text = getTaskText(project) ?: return null
196+
var text = runReadAction {
197+
getTaskText(project)
198+
} ?: return null
199+
192200
text = StringUtil.replace(text, "%IDE_NAME%", ApplicationNamesInfo.getInstance().fullProductName)
193201
val textBuffer = StringBuffer(text)
194202
replaceActionIDsWithShortcuts(textBuffer)

intellij-plugin/hs-core/src/org/hyperskill/academy/learning/stepik/hyperskill/courseGeneration/HyperskillTaskBuilder.kt

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import org.hyperskill.academy.learning.courseFormat.CheckStatus
66
import org.hyperskill.academy.learning.courseFormat.Course
77
import org.hyperskill.academy.learning.courseFormat.EduFileErrorHighlightLevel
88
import org.hyperskill.academy.learning.courseFormat.tasks.*
9-
import org.hyperskill.academy.learning.courseFormat.tasks.EduTask.Companion.PYCHARM_TASK_TYPE
10-
import org.hyperskill.academy.learning.courseFormat.tasks.RemoteEduTask.Companion.REMOTE_EDU_TASK_TYPE
119
import org.hyperskill.academy.learning.stepik.PyCharmStepOptions
1210
import org.hyperskill.academy.learning.stepik.StepikTaskBuilder
1311
import org.hyperskill.academy.learning.stepik.hasHeaderOrFooter
@@ -25,17 +23,13 @@ class HyperskillTaskBuilder(
2523
return HyperskillLanguages.getLanguageName(language.id)
2624
}
2725

28-
fun build(): Task? {
29-
val blockName = stepSource.block?.name ?: return null
26+
fun build(): Task? = when (val blockName = stepSource.block?.name) {
27+
EduTask.PYCHARM_TASK_TYPE if stepSource.isRemoteTested -> createTask(RemoteEduTask.REMOTE_EDU_TASK_TYPE)
28+
EduTask.PYCHARM_TASK_TYPE,
29+
"text",
30+
CodeTask.CODE_TASK_TYPE -> createTask(blockName)
3031

31-
val type = if (blockName == PYCHARM_TASK_TYPE && stepSource.isRemoteTested) {
32-
REMOTE_EDU_TASK_TYPE
33-
}
34-
else {
35-
blockName
36-
}
37-
38-
return createTask(type)
32+
else -> null
3933
}
4034

4135
override fun createTask(type: String): Task {

intellij-plugin/hs-core/src/org/hyperskill/academy/learning/taskToolWindow/ui/TaskToolWindow.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package org.hyperskill.academy.learning.taskToolWindow.ui
1717

1818
import com.intellij.openapi.Disposable
19-
import com.intellij.openapi.application.runReadAction
2019
import com.intellij.openapi.project.Project
2120
import com.intellij.openapi.util.registry.Registry
2221
import com.intellij.util.ui.update.MergingUpdateQueue
@@ -65,10 +64,8 @@ abstract class TaskToolWindow(protected val project: Project) : Disposable {
6564
const val TASK_DESCRIPTION_UPDATE_DELAY_REGISTRY_KEY: String = "hyperskill.task.description.update.delay"
6665

6766
fun getTaskDescription(project: Project, task: Task?, uiMode: JavaUILibrary): String {
68-
val openedTask = task ?: return EduCoreBundle.message("label.open.task")
69-
val taskText = runReadAction {
70-
openedTask.getFormattedTaskText(project)
71-
} ?: return EduCoreBundle.message("label.open.task")
67+
val taskText = task?.getFormattedTaskText(project)
68+
?: return EduCoreBundle.message("label.open.task")
7269
val transformerContext = HtmlTransformerContext(project, task, uiMode)
7370
return TaskDescriptionTransformer.transform(taskText, transformerContext)
7471
}

0 commit comments

Comments
 (0)