diff --git a/docs/UtUtilsClass.md b/docs/UtUtilsClass.md
index 63279678a2..ed1cfeab51 100644
--- a/docs/UtUtilsClass.md
+++ b/docs/UtUtilsClass.md
@@ -12,11 +12,13 @@ Previously UnitTestBot generated _utility methods_ for each test class when they
For now UnitTestBot provides a special `UtUtils` class containing all _utility methods_ if at least one test class needs some of them. This class is generated once and the specific methods are imported from it if necessary. No need for _utility methods_ — no `UtUtils` class is generated.
+We create a separate `UtUtils` class for each supported codegen language (if this class is required).
+
## What does it look like
-Here is an example of a comment inherent to every `UtUtils` class:
+Here is an example of documentation comment inherent to every `UtUtils` class:
-
+
As one can see, the comment mentions two characteristics of the `UtUtils` class:
@@ -39,7 +41,7 @@ rely on the proper methods from `UtUtils` class.
## Where to find it
-`UtUtils` class is usually located in the chosen **Test sources root** near the generated test classes.
+`UtUtils` class is usually located in the chosen **Test sources root** near the generated test classes. The corresponding package name mentions the language of the generated tests: e.g. `org.utbot.runtime.utils.java`.
## How to test
diff --git a/docs/images/utbot_ututils_2.0.png b/docs/images/utbot_ututils_2.0.png
new file mode 100644
index 0000000000..c1146646c3
Binary files /dev/null and b/docs/images/utbot_ututils_2.0.png differ
diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/models/CgElement.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/models/CgElement.kt
index 0c32541cbd..a37ea56bbb 100644
--- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/models/CgElement.kt
+++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/models/CgElement.kt
@@ -124,6 +124,7 @@ open class CgClassFile(
class CgClass(
val id: ClassId,
+ val documentation: CgDocumentationComment?,
val annotations: List,
val superclass: ClassId?,
val interfaces: List,
@@ -149,7 +150,6 @@ class CgClass(
*/
class CgClassBody(
val classId: ClassId,
- val documentation: CgDocumentationComment?,
val methodRegions: List,
val staticDeclarationRegions: List,
val nestedClassRegions: List>
diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/CodeGenerator.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/CodeGenerator.kt
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/renderer/CgJavaRenderer.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/renderer/CgJavaRenderer.kt
index 6e1ecefb7b..80a6630243 100644
--- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/renderer/CgJavaRenderer.kt
+++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/renderer/CgJavaRenderer.kt
@@ -61,6 +61,8 @@ internal class CgJavaRenderer(context: CgRendererContext, printer: CgPrinter = C
get() = this == context.generatedClass
override fun visit(element: CgClass) {
+ element.documentation?.accept(this)
+
for (annotation in element.annotations) {
annotation.accept(this)
}
diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/renderer/CgKotlinRenderer.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/renderer/CgKotlinRenderer.kt
index 229c33d697..70531d610e 100644
--- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/renderer/CgKotlinRenderer.kt
+++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/renderer/CgKotlinRenderer.kt
@@ -75,6 +75,8 @@ internal class CgKotlinRenderer(context: CgRendererContext, printer: CgPrinter =
get() = (this == context.generatedClass) || isKotlinFile
override fun visit(element: CgClass) {
+ element.documentation?.accept(this)
+
for (annotation in element.annotations) {
annotation.accept(this)
}
@@ -115,8 +117,6 @@ internal class CgKotlinRenderer(context: CgRendererContext, printer: CgPrinter =
}
override fun visit(element: CgClassBody) {
- element.documentation?.accept(this)
-
// render regions for test methods
for ((i, region) in (element.methodRegions + element.nestedClassRegions).withIndex()) {
if (i != 0) println()
diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/Builders.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/Builders.kt
index 70b7344bf8..90b5d0b54e 100644
--- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/Builders.kt
+++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/Builders.kt
@@ -49,6 +49,7 @@ fun buildClassFile(init: CgClassFileBuilder.() -> Unit) = CgClassFileBuilder().a
class CgClassBuilder : CgBuilder {
lateinit var id: ClassId
+ var documentation: CgDocumentationComment? = null
val annotations: MutableList = mutableListOf()
var superclass: ClassId? = null
val interfaces: MutableList = mutableListOf()
@@ -56,18 +57,17 @@ class CgClassBuilder : CgBuilder {
var isNested: Boolean = false
lateinit var body: CgClassBody
- override fun build() = CgClass(id, annotations, superclass, interfaces, body, isStatic, isNested)
+ override fun build() = CgClass(id, documentation, annotations, superclass, interfaces, body, isStatic, isNested)
}
fun buildClass(init: CgClassBuilder.() -> Unit) = CgClassBuilder().apply(init).build()
class CgClassBodyBuilder(val classId: ClassId) : CgBuilder {
- var documentation: CgDocumentationComment? = null
val methodRegions: MutableList = mutableListOf()
val staticDeclarationRegions: MutableList = mutableListOf()
val nestedClassRegions: MutableList> = mutableListOf()
- override fun build() = CgClassBody(classId, documentation, methodRegions, staticDeclarationRegions, nestedClassRegions)
+ override fun build() = CgClassBody(classId, methodRegions, staticDeclarationRegions, nestedClassRegions)
}
fun buildClassBody(classId: ClassId, init: CgClassBodyBuilder.() -> Unit) = CgClassBodyBuilder(classId).apply(init).build()
diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/ututils/CgUtilClassConstructor.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/ututils/CgUtilClassConstructor.kt
index c0aee58cd8..d267d062a2 100644
--- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/ututils/CgUtilClassConstructor.kt
+++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/ututils/CgUtilClassConstructor.kt
@@ -27,8 +27,8 @@ internal object CgUtilClassConstructor {
// so they will be imported once IDEA reformatting action has worked
declaredClass = buildClass {
id = utilsClassId
+ documentation = utilClassKind.utilClassDocumentation(codegenLanguage)
body = buildClassBody(utilsClassId) {
- documentation = utilClassKind.utilClassDocumentation(codegenLanguage)
staticDeclarationRegions += CgStaticsRegion("Util methods", utilMethodProvider.utilMethodIds.map { CgUtilMethod(it) })
nestedClassRegions += CgAuxiliaryNestedClassesRegion(
nestedClasses = listOf(
diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/ututils/UtilClassKind.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/ututils/UtilClassKind.kt
index 65222922a9..a38e0b4655 100644
--- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/ututils/UtilClassKind.kt
+++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/ututils/UtilClassKind.kt
@@ -35,7 +35,7 @@ sealed class UtilClassKind(
fun utilClassDocumentation(codegenLanguage: CodegenLanguage): CgDocumentationComment
= CgDocumentationComment(
listOf(
- CgDocRegularStmt(utilClassKindCommentText),
+ CgDocRegularStmt("$utilClassKindCommentText \n"),
CgDocRegularStmt("$UTIL_CLASS_VERSION_COMMENT_PREFIX${utilClassVersion(codegenLanguage)}"),
)
)