From b143d3e47eead6902e2c16118b8901275ad5d2f0 Mon Sep 17 00:00:00 2001 From: mikrise2 Date: Thu, 11 Jan 2024 20:37:23 +0100 Subject: [PATCH] [ML4SE-302] code cleaned --- .../config/content/TaskContentConfig.kt | 2 +- .../research/tasktracker/models/Extension.kt | 3 ++- .../tasktracker/tracking/TaskFileHandler.kt | 4 ++-- .../research/tasktracker/tracking/Util.kt | 2 +- .../config/task_content_default.yaml | 17 +++++++++-------- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/content/TaskContentConfig.kt b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/content/TaskContentConfig.kt index 7a955b4b..b146a961 100644 --- a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/content/TaskContentConfig.kt +++ b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/content/TaskContentConfig.kt @@ -28,7 +28,7 @@ data class TaskContentConfig(val tasks: List) : BaseConfig { config.tasks.forEach { task -> task.language?.let { task.files.forEach { fileInfo -> - fileInfo.extension = it + fileInfo.extension = fileInfo.extension ?: it fileInfo.relativePath = getRelativePath(task, fileInfo) fileInfo.content = fileInfo.gatherContent() } diff --git a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/models/Extension.kt b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/models/Extension.kt index e1483a9f..e2a0b6c0 100644 --- a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/models/Extension.kt +++ b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/models/Extension.kt @@ -6,5 +6,6 @@ enum class Extension(val ext: String) { JAVA(".java"), KOTLIN(".kt"), CPP(".cpp"), - CSV(".csv") + CSV(".csv"), + NO_EXTENSION("") } diff --git a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/tracking/TaskFileHandler.kt b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/tracking/TaskFileHandler.kt index c686309d..67d30b8f 100644 --- a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/tracking/TaskFileHandler.kt +++ b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/tracking/TaskFileHandler.kt @@ -134,9 +134,9 @@ object TaskFileHandler { } private fun getPath(project: Project, taskFile: ITaskFileInfo, task: TaskWithFiles): String = buildString { - append("${project.basePath}/") + append("${project.basePath}") if (taskFile.isInternal) { - append("$PLUGIN_NAME/${taskFile.extension?.getDirectoryName() ?: ""}") + append("/$PLUGIN_NAME/${taskFile.extension?.getDirectoryName() ?: ""}") append("${task.root.pathOrEmpty()}/${taskFile.sourceSet.path}") } append("${taskFile.relativePath.toPackageName().pathOrEmpty()}/") diff --git a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/tracking/Util.kt b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/tracking/Util.kt index 941e7ed1..d7e84225 100644 --- a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/tracking/Util.kt +++ b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/tracking/Util.kt @@ -4,6 +4,6 @@ import org.jetbrains.research.tasktracker.models.Extension import java.util.* fun String.toPackageName() = - listOf(" ", "-", "_").fold(this) { acc, s -> acc.replace(s, "") }.lowercase(Locale.getDefault()) + listOf(" ", "-", "_").fold(this) { acc, s -> acc.replace(s, "") } fun Extension.getDirectoryName() = this.name.lowercase(Locale.getDefault()) diff --git a/ij-plugin/src/main/resources/org/jetbrains/research/tasktracker/config/task_content_default.yaml b/ij-plugin/src/main/resources/org/jetbrains/research/tasktracker/config/task_content_default.yaml index ec10f550..519c3559 100644 --- a/ij-plugin/src/main/resources/org/jetbrains/research/tasktracker/config/task_content_default.yaml +++ b/ij-plugin/src/main/resources/org/jetbrains/research/tasktracker/config/task_content_default.yaml @@ -8,11 +8,11 @@ tasks: sourceSet: "SRC" isInternal: false - filename: "Task" - relativePath: "CodeStyleAndFormatting/WhatIsFormatting/ReformatTheCode/src/main/kotlin/jetbrains/refactoring/course/formatting" + relativePath: "CodeStyleAndFormatting/WhatIsFormatting/ReformatTheCodePractice/src/main/kotlin/jetbrains/refactoring/course/formatting" sourceSet: "SRC" isInternal: false - filename: "Task" - relativePath: "CodeStyleAndFormatting/WhatIsFormatting/ReformatTheCodeUsingIDE/src/main/kotlin/jetbrains/refactoring/course/formatting" + relativePath: "CodeStyleAndFormatting/WhatIsFormatting/ReformatTheCodeUsingIDEPractice/src/main/kotlin/jetbrains/refactoring/course/formatting" sourceSet: "SRC" isInternal: false - filename: "Task" @@ -21,14 +21,15 @@ tasks: isInternal: false - filename: ".editorconfig" relativePath: "CodeStyleAndFormatting/CodeSchemasAndEditorConfig/task" + extension: NO_EXTENSION sourceSet: "SRC" isInternal: false - filename: "Student" - relativePath: "RenamingCode/RenameRefactoringInIDE/FixTypos/src/main/kotlin/jetbrains/refactoring/course/renaming" + relativePath: "RenamingCode/RenameRefactoringInIDE/FixTyposPractice/src/main/kotlin/jetbrains/refactoring/course/renaming" sourceSet: "SRC" isInternal: false - filename: "University" - relativePath: "RenamingCode/RenameRefactoringInIDE/FixTypos/src/main/kotlin/jetbrains/refactoring/course/renaming" + relativePath: "RenamingCode/RenameRefactoringInIDE/FixTyposPractice/src/main/kotlin/jetbrains/refactoring/course/renaming" sourceSet: "SRC" isInternal: false - filename: "Main" @@ -56,19 +57,19 @@ tasks: sourceSet: "SRC" isInternal: false - filename: "Task" - relativePath: "ExtractingCode/WhatIsExtractMethodRefactoring/ExtractDuplicatedCode/src/main/kotlin/jetbrains/refactoring/course/extracting" + relativePath: "ExtractingCode/WhatIsExtractMethodRefactoring/ExtractDuplicatedCodePractice/src/main/kotlin/jetbrains/refactoring/course/extracting" sourceSet: "SRC" isInternal: false - filename: "Task" - relativePath: "ExtractingCode/WhatIsExtractVariableRefactoring/ExtractMagicConstants/src/main/kotlin/jetbrains/refactoring/course/extracting" + relativePath: "ExtractingCode/WhatIsExtractVariableRefactoring/ExtractMagicConstantsPractice/src/main/kotlin/jetbrains/refactoring/course/extracting" sourceSet: "SRC" isInternal: false - filename: "Task" - relativePath: "InliningCode/WhatIsInlineVariableRefactoring/InlineVariables/src/main/kotlin/jetbrains/refactoring/course/inlining" + relativePath: "InliningCode/WhatIsInlineVariableRefactoring/InlineVariablesPractice/src/main/kotlin/jetbrains/refactoring/course/inlining" sourceSet: "SRC" isInternal: false - filename: "Task" - relativePath: "InliningCode/InlineMethodRefactoring/InlineMethodAndVariables/src/main/kotlin/jetbrains/refactoring/course/inlining" + relativePath: "InliningCode/InlineMethodRefactoring/InlineMethodAndVariablesPractice/src/main/kotlin/jetbrains/refactoring/course/inlining" sourceSet: "SRC" isInternal: false - filename: "MiddleMan"