File tree Expand file tree Collapse file tree 5 files changed +23
-7
lines changed
utbot-framework/src/main/kotlin/org/utbot/framework/codegen
utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api
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() {
1428
1428
1429
1429
override fun hashCode (): Int = stmt.hashCode()
1430
1430
}
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
15
15
import org.utbot.framework.plugin.api.DocCustomTagStatement
16
16
import org.utbot.framework.plugin.api.DocMethodLinkStmt
17
17
import org.utbot.framework.plugin.api.DocPreTagStatement
18
+ import org.utbot.framework.plugin.api.DocRegularLineStmt
18
19
import org.utbot.framework.plugin.api.DocRegularStmt
19
20
import org.utbot.framework.plugin.api.DocStatement
20
21
import org.utbot.framework.plugin.api.ExecutableId
@@ -473,6 +474,7 @@ fun convertDocToCg(stmt: DocStatement): CgDocStatement {
473
474
CgCustomTagStatement (statements = stmts)
474
475
}
475
476
is DocRegularStmt -> CgDocRegularStmt (stmt = stmt.stmt)
477
+ is DocRegularLineStmt -> CgDocRegularLineStmt (stmt = stmt.stmt)
476
478
is DocClassLinkStmt -> CgDocClassLinkStmt (className = stmt.className)
477
479
is DocMethodLinkStmt -> CgDocMethodLinkStmt (methodName = stmt.methodName, stmt = stmt.className)
478
480
is DocCodeStmt -> CgDocCodeStmt (stmt = stmt.stmt)
Original file line number Diff line number Diff line change @@ -330,7 +330,7 @@ abstract class CgAbstractRenderer(
330
330
if (element.lines.all { it.isEmpty() }) return
331
331
332
332
println (" /**" )
333
- for (line in element.lines) line .accept(this )
333
+ element.lines.forEach { it .accept(this ) }
334
334
println (" */" )
335
335
}
336
336
override fun visit (element : CgDocPreTagStatement ) {
@@ -343,9 +343,7 @@ abstract class CgAbstractRenderer(
343
343
override fun visit (element : CgCustomTagStatement ) {
344
344
if (element.statements.all { it.isEmpty() }) return
345
345
346
- for (stmt in element.statements) {
347
- stmt.accept(this )
348
- }
346
+ element.statements.forEach { it.accept(this ) }
349
347
}
350
348
351
349
override fun visit (element : CgDocCodeStmt ) {
@@ -366,7 +364,10 @@ abstract class CgAbstractRenderer(
366
364
override fun visit (element : CgDocRegularLineStmt ){
367
365
if (element.isEmpty()) return
368
366
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)
370
371
}
371
372
override fun visit (element : CgDocClassLinkStmt ) {
372
373
if (element.isEmpty()) return
Original file line number Diff line number Diff line change 1
1
package org.utbot.summary.comment.customtags.symbolic
2
2
3
+ import org.utbot.framework.plugin.api.DocRegularLineStmt
3
4
import org.utbot.framework.plugin.api.DocRegularStmt
5
+ import org.utbot.framework.plugin.api.DocStatement
4
6
import org.utbot.summary.comment.customtags.fuzzer.CommentWithCustomTagForTestProducedByFuzzer
5
7
6
8
/* *
@@ -85,11 +87,11 @@ sealed class CustomJavaDocTag(
85
87
}
86
88
87
89
// 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 ? {
89
91
if (valueRetrieverFuzzer != null ) { // TODO: it required only when we have two different retrievers
90
92
return when (val value = valueRetrieverFuzzer!! .invoke(comment)) { // TODO: unsafe !! - resolve
91
93
is String -> value.takeIf { it.isNotEmpty() }?.let {
92
- DocRegularStmt (" @$name $value \n " )
94
+ DocRegularLineStmt (" @$name $value " )
93
95
}
94
96
95
97
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
24
24
import org.utbot.framework.plugin.api.DocCustomTagStatement
25
25
import org.utbot.framework.plugin.api.DocMethodLinkStmt
26
26
import org.utbot.framework.plugin.api.DocPreTagStatement
27
+ import org.utbot.framework.plugin.api.DocRegularLineStmt
27
28
import org.utbot.framework.plugin.api.DocRegularStmt
28
29
import org.utbot.framework.plugin.api.DocStatement
29
30
import org.utbot.framework.plugin.api.ExecutableId
@@ -2827,6 +2828,7 @@ private fun flattenDocStatements(summary: List<DocStatement>): List<DocStatement
2827
2828
is DocMethodLinkStmt -> flatten.add(s)
2828
2829
is DocCodeStmt -> flatten.add(s)
2829
2830
is DocRegularStmt -> flatten.add(s)
2831
+ is DocRegularLineStmt -> flatten.add(s)
2830
2832
is DocCustomTagStatement -> flatten.add(s)
2831
2833
}
2832
2834
}
You can’t perform that action at this time.
0 commit comments