Skip to content

Commit 04c85da

Browse files
authored
Fix UtUtils version parsing & comment formatting #1378 #1380 #1385 (#1401)
Fix utUtil version parsing & fix the comment & give a name to the region
1 parent d7ad5ed commit 04c85da

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/renderer/CgAbstractRenderer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ abstract class CgAbstractRenderer(
360360
override fun visit(element: CgDocRegularStmt){
361361
if (element.isEmpty()) return
362362

363-
print(element.stmt.replace("\n", "\n * "))
363+
print(" * " + element.stmt)
364364
}
365365
override fun visit(element: CgDocClassLinkStmt) {
366366
if (element.isEmpty()) return

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/ututils/CgUtilClassConstructor.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ internal object CgUtilClassConstructor {
2929
id = utilsClassId
3030
documentation = utilClassKind.utilClassDocumentation(codegenLanguage)
3131
body = buildClassBody(utilsClassId) {
32-
staticDeclarationRegions += CgStaticsRegion("Util methods", utilMethodProvider.utilMethodIds.map { CgUtilMethod(it) })
32+
staticDeclarationRegions += CgStaticsRegion(
33+
header = "Util methods",
34+
content = utilMethodProvider.utilMethodIds.map { CgUtilMethod(it) })
35+
3336
nestedClassRegions += CgAuxiliaryNestedClassesRegion(
37+
header = "Util classes",
3438
nestedClasses = listOf(
3539
CgAuxiliaryClass(utilMethodProvider.capturedArgumentClassId)
3640
)

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/ututils/UtilClassKind.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ sealed class UtilClassKind(
3636
= CgDocumentationComment(
3737
listOf(
3838
CgDocRegularStmt("$utilClassKindCommentText \n"),
39-
CgDocRegularStmt("$UTIL_CLASS_VERSION_COMMENT_PREFIX${utilClassVersion(codegenLanguage)}"),
39+
CgDocRegularStmt("$UTIL_CLASS_VERSION_COMMENT_PREFIX${utilClassVersion(codegenLanguage)} \n"),
4040
)
4141
)
4242

@@ -108,9 +108,9 @@ sealed class UtilClassKind(
108108
codegenLanguage: CodegenLanguage
109109
)
110110
: UtilClassKind? {
111-
return when (comment) {
112-
RegularUtUtils(codegenLanguage).utilClassKindCommentText -> RegularUtUtils(codegenLanguage)
113-
UtUtilsWithMockito(codegenLanguage).utilClassKindCommentText -> UtUtilsWithMockito(codegenLanguage)
111+
return when {
112+
comment.contains(RegularUtUtils(codegenLanguage).utilClassKindCommentText) -> RegularUtUtils(codegenLanguage)
113+
comment.contains(UtUtilsWithMockito(codegenLanguage).utilClassKindCommentText) -> UtUtilsWithMockito(codegenLanguage)
114114
else -> null
115115
}
116116
}

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/CodeGenerationController.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ object CodeGenerationController {
426426
.map { comment -> comment.text }
427427
.firstOrNull { text -> UtilClassKind.UTIL_CLASS_VERSION_COMMENT_PREFIX in text }
428428
?.substringAfterLast(UtilClassKind.UTIL_CLASS_VERSION_COMMENT_PREFIX)
429+
?.substringBefore("\n")
429430
?.trim()
430431
}
431432

0 commit comments

Comments
 (0)