Skip to content

Commit a2cd026

Browse files
authored
Fix plain JavaDocs formatting #1430 (#1436)
1 parent 169c4fd commit a2cd026

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/models/CgElement.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import org.utbot.framework.codegen.renderer.CgRendererContext
77
import org.utbot.framework.codegen.renderer.CgVisitor
88
import org.utbot.framework.codegen.renderer.auxiliaryClassTextById
99
import org.utbot.framework.codegen.renderer.utilMethodTextById
10-
import org.utbot.framework.codegen.reports.TestsGenerationReport
1110
import org.utbot.framework.plugin.api.BuiltinClassId
1211
import org.utbot.framework.plugin.api.ClassId
1312
import org.utbot.framework.plugin.api.ConstructorId
@@ -60,6 +59,7 @@ interface CgElement {
6059
is CgCustomTagStatement -> visit(element)
6160
is CgDocCodeStmt -> visit(element)
6261
is CgDocRegularStmt -> visit(element)
62+
is CgDocRegularLineStmt -> visit(element)
6363
is CgDocClassLinkStmt -> visit(element)
6464
is CgDocMethodLinkStmt -> visit(element)
6565
is CgAnonymousFunction -> visit(element)
@@ -423,7 +423,19 @@ class CgDocRegularStmt(val stmt: String) : CgDocStatement() {
423423
override fun isEmpty(): Boolean = stmt.isEmpty()
424424

425425
override fun equals(other: Any?): Boolean =
426-
if (other is CgDocCodeStmt) this.hashCode() == other.hashCode() else false
426+
if (other is CgDocRegularStmt) this.hashCode() == other.hashCode() else false
427+
428+
override fun hashCode(): Int = stmt.hashCode()
429+
}
430+
431+
/**
432+
* Represents an element of a whole line of a multiline comment.
433+
*/
434+
class CgDocRegularLineStmt(val stmt: String) : CgDocStatement() {
435+
override fun isEmpty(): Boolean = stmt.isEmpty()
436+
437+
override fun equals(other: Any?): Boolean =
438+
if (other is CgDocRegularLineStmt) this.hashCode() == other.hashCode() else false
427439

428440
override fun hashCode(): Int = stmt.hashCode()
429441
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import org.utbot.framework.codegen.domain.models.CgDocClassLinkStmt
2929
import org.utbot.framework.codegen.domain.models.CgDocCodeStmt
3030
import org.utbot.framework.codegen.domain.models.CgDocMethodLinkStmt
3131
import org.utbot.framework.codegen.domain.models.CgDocPreTagStatement
32+
import org.utbot.framework.codegen.domain.models.CgDocRegularLineStmt
3233
import org.utbot.framework.codegen.domain.models.CgDocRegularStmt
3334
import org.utbot.framework.codegen.domain.models.CgDocumentationComment
3435
import org.utbot.framework.codegen.domain.models.CgElement
@@ -360,7 +361,12 @@ abstract class CgAbstractRenderer(
360361
override fun visit(element: CgDocRegularStmt){
361362
if (element.isEmpty()) return
362363

363-
print(" * " + element.stmt)
364+
print(element.stmt.replace("\n", "\n * "))
365+
}
366+
override fun visit(element: CgDocRegularLineStmt){
367+
if (element.isEmpty()) return
368+
369+
print(" * " + element.stmt + "\n")
364370
}
365371
override fun visit(element: CgDocClassLinkStmt) {
366372
if (element.isEmpty()) return

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ import org.utbot.framework.codegen.domain.models.CgSwitchCase
7575
import org.utbot.framework.codegen.domain.models.CgSwitchCaseLabel
7676
import org.utbot.framework.codegen.domain.models.CgClass
7777
import org.utbot.framework.codegen.domain.models.CgClassBody
78+
import org.utbot.framework.codegen.domain.models.CgDocRegularLineStmt
7879
import org.utbot.framework.codegen.domain.models.CgNestedClassesRegion
7980
import org.utbot.framework.codegen.domain.models.CgTestMethod
8081
import org.utbot.framework.codegen.domain.models.CgTestMethodCluster
@@ -132,6 +133,7 @@ interface CgVisitor<R> {
132133
fun visit(element: CgCustomTagStatement): R
133134
fun visit(element: CgDocCodeStmt): R
134135
fun visit(element: CgDocRegularStmt): R
136+
fun visit(element: CgDocRegularLineStmt): R
135137
fun visit(element: CgDocClassLinkStmt): R
136138
fun visit(element: CgDocMethodLinkStmt): R
137139

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package org.utbot.framework.codegen.tree.ututils
22

33
import org.utbot.framework.codegen.domain.builtin.UtilClassFileMethodProvider
44
import org.utbot.framework.codegen.domain.context.CgContext
5-
import org.utbot.framework.codegen.domain.models.CgDocRegularStmt
5+
import org.utbot.framework.codegen.domain.models.CgDocRegularLineStmt
66
import org.utbot.framework.codegen.domain.models.CgDocumentationComment
77
import org.utbot.framework.codegen.renderer.CgAbstractRenderer
88
import org.utbot.framework.plugin.api.CodegenLanguage
@@ -35,8 +35,8 @@ sealed class UtilClassKind(
3535
fun utilClassDocumentation(codegenLanguage: CodegenLanguage): CgDocumentationComment
3636
= CgDocumentationComment(
3737
listOf(
38-
CgDocRegularStmt("$utilClassKindCommentText \n"),
39-
CgDocRegularStmt("$UTIL_CLASS_VERSION_COMMENT_PREFIX${utilClassVersion(codegenLanguage)} \n"),
38+
CgDocRegularLineStmt(utilClassKindCommentText),
39+
CgDocRegularLineStmt("$UTIL_CLASS_VERSION_COMMENT_PREFIX${utilClassVersion(codegenLanguage)}"),
4040
)
4141
)
4242

0 commit comments

Comments
 (0)