File tree Expand file tree Collapse file tree 5 files changed +23
-7
lines changed
utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api
utbot-framework/src/main/kotlin/org/utbot/framework/codegen
utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags
utbot-testing/src/main/kotlin/org/utbot/testing Expand file tree Collapse file tree 5 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -1428,3 +1428,12 @@ class DocRegularStmt(val stmt: String) : DocStatement() {
14281428
14291429 override fun hashCode (): Int = stmt.hashCode()
14301430}
1431+
1432+ class DocRegularLineStmt (val stmt : String ) : DocStatement() {
1433+ override fun toString (): String = stmt
1434+
1435+ override fun equals (other : Any? ): Boolean =
1436+ if (other is DocRegularLineStmt ) this .hashCode() == other.hashCode() else false
1437+
1438+ override fun hashCode (): Int = stmt.hashCode()
1439+ }
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import org.utbot.framework.plugin.api.DocCodeStmt
1515import org.utbot.framework.plugin.api.DocCustomTagStatement
1616import org.utbot.framework.plugin.api.DocMethodLinkStmt
1717import org.utbot.framework.plugin.api.DocPreTagStatement
18+ import org.utbot.framework.plugin.api.DocRegularLineStmt
1819import org.utbot.framework.plugin.api.DocRegularStmt
1920import org.utbot.framework.plugin.api.DocStatement
2021import org.utbot.framework.plugin.api.ExecutableId
@@ -473,6 +474,7 @@ fun convertDocToCg(stmt: DocStatement): CgDocStatement {
473474 CgCustomTagStatement (statements = stmts)
474475 }
475476 is DocRegularStmt -> CgDocRegularStmt (stmt = stmt.stmt)
477+ is DocRegularLineStmt -> CgDocRegularLineStmt (stmt = stmt.stmt)
476478 is DocClassLinkStmt -> CgDocClassLinkStmt (className = stmt.className)
477479 is DocMethodLinkStmt -> CgDocMethodLinkStmt (methodName = stmt.methodName, stmt = stmt.className)
478480 is DocCodeStmt -> CgDocCodeStmt (stmt = stmt.stmt)
Original file line number Diff line number Diff line change @@ -330,7 +330,7 @@ abstract class CgAbstractRenderer(
330330 if (element.lines.all { it.isEmpty() }) return
331331
332332 println (" /**" )
333- for (line in element.lines) line .accept(this )
333+ element.lines.forEach { it .accept(this ) }
334334 println (" */" )
335335 }
336336 override fun visit (element : CgDocPreTagStatement ) {
@@ -343,9 +343,7 @@ abstract class CgAbstractRenderer(
343343 override fun visit (element : CgCustomTagStatement ) {
344344 if (element.statements.all { it.isEmpty() }) return
345345
346- for (stmt in element.statements) {
347- stmt.accept(this )
348- }
346+ element.statements.forEach { it.accept(this ) }
349347 }
350348
351349 override fun visit (element : CgDocCodeStmt ) {
@@ -366,7 +364,10 @@ abstract class CgAbstractRenderer(
366364 override fun visit (element : CgDocRegularLineStmt ){
367365 if (element.isEmpty()) return
368366
369- print (" * " + element.stmt + " \n " )
367+ // It is better to avoid using \n in print, using println is preferred.
368+ // Mixing println's and print's with '\n' BREAKS indention.
369+ // See [https://stackoverflow.com/questions/6685665/system-out-println-vs-n-in-java].
370+ println (" * " + element.stmt)
370371 }
371372 override fun visit (element : CgDocClassLinkStmt ) {
372373 if (element.isEmpty()) return
Original file line number Diff line number Diff line change 11package org.utbot.summary.comment.customtags.symbolic
22
3+ import org.utbot.framework.plugin.api.DocRegularLineStmt
34import org.utbot.framework.plugin.api.DocRegularStmt
5+ import org.utbot.framework.plugin.api.DocStatement
46import org.utbot.summary.comment.customtags.fuzzer.CommentWithCustomTagForTestProducedByFuzzer
57
68/* *
@@ -85,11 +87,11 @@ sealed class CustomJavaDocTag(
8587 }
8688
8789 // TODO: could be universal with the function above after creation of hierarchy data classes related to the comments
88- fun generateDocStatementForTestProducedByFuzzer (comment : CommentWithCustomTagForTestProducedByFuzzer ): DocRegularStmt ? {
90+ fun generateDocStatementForTestProducedByFuzzer (comment : CommentWithCustomTagForTestProducedByFuzzer ): DocStatement ? {
8991 if (valueRetrieverFuzzer != null ) { // TODO: it required only when we have two different retrievers
9092 return when (val value = valueRetrieverFuzzer!! .invoke(comment)) { // TODO: unsafe !! - resolve
9193 is String -> value.takeIf { it.isNotEmpty() }?.let {
92- DocRegularStmt (" @$name $value \n " )
94+ DocRegularLineStmt (" @$name $value " )
9395 }
9496
9597 is List <* > -> value.takeIf { it.isNotEmpty() }?.let {
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import org.utbot.framework.plugin.api.DocCodeStmt
2424import org.utbot.framework.plugin.api.DocCustomTagStatement
2525import org.utbot.framework.plugin.api.DocMethodLinkStmt
2626import org.utbot.framework.plugin.api.DocPreTagStatement
27+ import org.utbot.framework.plugin.api.DocRegularLineStmt
2728import org.utbot.framework.plugin.api.DocRegularStmt
2829import org.utbot.framework.plugin.api.DocStatement
2930import org.utbot.framework.plugin.api.ExecutableId
@@ -2827,6 +2828,7 @@ private fun flattenDocStatements(summary: List<DocStatement>): List<DocStatement
28272828 is DocMethodLinkStmt -> flatten.add(s)
28282829 is DocCodeStmt -> flatten.add(s)
28292830 is DocRegularStmt -> flatten.add(s)
2831+ is DocRegularLineStmt -> flatten.add(s)
28302832 is DocCustomTagStatement -> flatten.add(s)
28312833 }
28322834 }
You can’t perform that action at this time.
0 commit comments