Skip to content

Commit

Permalink
[ML4SE-302] code cleaned
Browse files Browse the repository at this point in the history
  • Loading branch information
mikrise2 committed Jan 11, 2024
1 parent f7be61a commit b143d3e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ data class TaskContentConfig(val tasks: List<ProgrammingTask>) : 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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ enum class Extension(val ext: String) {
JAVA(".java"),
KOTLIN(".kt"),
CPP(".cpp"),
CSV(".csv")
CSV(".csv"),
NO_EXTENSION("")
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()}/")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit b143d3e

Please sign in to comment.