Skip to content

Commit e136902

Browse files
committed
Add DocCustomTagStatement and CgCustomTagStatement
1 parent e6ca23b commit e136902

File tree

5 files changed

+36
-7
lines changed

5 files changed

+36
-7
lines changed

utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,14 @@ class DocPreTagStatement(content: List<DocStatement>) : DocTagStatement(content)
12761276
override fun hashCode(): Int = content.hashCode()
12771277
}
12781278

1279+
class DocCustomTagStatement(content: List<DocStatement>) : DocTagStatement(content) {
1280+
override fun toString(): String = content.joinToString(separator = "")
1281+
1282+
override fun equals(other: Any?): Boolean =
1283+
if (other is DocCustomTagStatement) this.hashCode() == other.hashCode() else false
1284+
1285+
override fun hashCode(): Int = content.hashCode()
1286+
}
12791287

12801288
open class DocClassLinkStmt(val className: String) : DocStatement() {
12811289
override fun toString(): String = className

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/tree/CgElement.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import org.utbot.framework.plugin.api.ClassId
1111
import org.utbot.framework.plugin.api.ConstructorId
1212
import org.utbot.framework.plugin.api.DocClassLinkStmt
1313
import org.utbot.framework.plugin.api.DocCodeStmt
14+
import org.utbot.framework.plugin.api.DocCustomTagStatement
1415
import org.utbot.framework.plugin.api.DocMethodLinkStmt
1516
import org.utbot.framework.plugin.api.DocPreTagStatement
1617
import org.utbot.framework.plugin.api.DocRegularStmt
@@ -52,6 +53,7 @@ interface CgElement {
5253
is CgMultilineComment -> visit(element)
5354
is CgDocumentationComment -> visit(element)
5455
is CgDocPreTagStatement -> visit(element)
56+
is CgCustomTagStatement -> visit(element)
5557
is CgDocCodeStmt -> visit(element)
5658
is CgDocRegularStmt -> visit(element)
5759
is CgDocClassLinkStmt -> visit(element)
@@ -335,6 +337,15 @@ class CgDocPreTagStatement(content: List<CgDocStatement>) : CgDocTagStatement(co
335337
override fun hashCode(): Int = content.hashCode()
336338
}
337339

340+
class CgCustomTagStatement(content: List<CgDocStatement>) : CgDocTagStatement(content) {
341+
override fun equals(other: Any?): Boolean =
342+
if (other is CgCustomTagStatement) {
343+
this.hashCode() == other.hashCode()
344+
} else false
345+
346+
override fun hashCode(): Int = content.hashCode()
347+
}
348+
338349
class CgDocCodeStmt(val stmt: String) : CgDocStatement() {
339350
override fun isEmpty(): Boolean = stmt.isEmpty()
340351

@@ -379,6 +390,10 @@ fun convertDocToCg(stmt: DocStatement): CgDocStatement {
379390
val stmts = stmt.content.map { convertDocToCg(it) }
380391
CgDocPreTagStatement(content = stmts)
381392
}
393+
is DocCustomTagStatement -> {
394+
val stmts = stmt.content.map { convertDocToCg(it) }
395+
CgCustomTagStatement(content = stmts)
396+
}
382397
is DocRegularStmt -> CgDocRegularStmt(stmt = stmt.stmt)
383398
is DocClassLinkStmt -> CgDocClassLinkStmt(className = stmt.className)
384399
is DocMethodLinkStmt -> CgDocMethodLinkStmt(methodName = stmt.methodName, stmt = stmt.className)

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import org.utbot.framework.codegen.model.tree.CgComment
1616
import org.utbot.framework.codegen.model.tree.CgCommentedAnnotation
1717
import org.utbot.framework.codegen.model.tree.CgComparison
1818
import org.utbot.framework.codegen.model.tree.CgContinueStatement
19+
import org.utbot.framework.codegen.model.tree.CgCustomTagStatement
1920
import org.utbot.framework.codegen.model.tree.CgDeclaration
2021
import org.utbot.framework.codegen.model.tree.CgDecrement
2122
import org.utbot.framework.codegen.model.tree.CgDoWhileLoop
@@ -92,7 +93,6 @@ import org.utbot.framework.plugin.api.util.isArray
9293
import org.utbot.framework.plugin.api.util.isRefType
9394
import org.utbot.framework.plugin.api.util.longClassId
9495
import org.utbot.framework.plugin.api.util.shortClassId
95-
import org.utbot.summary.UtSummarySettings
9696

9797
internal abstract class CgAbstractRenderer(val context: CgContext, val printer: CgPrinter = CgPrinterImpl()) : CgVisitor<Unit>,
9898
CgPrinter by printer {
@@ -310,12 +310,16 @@ internal abstract class CgAbstractRenderer(val context: CgContext, val printer:
310310
}
311311
override fun visit(element: CgDocPreTagStatement) {
312312
if (element.content.all { it.isEmpty() }) return
313-
// Don't add <pre> tag if custom javadoc tags are used.
314-
val shouldAddPreTag = !UtSummarySettings.USE_CUSTOM_JAVADOC_TAGS
315-
if (shouldAddPreTag) println("<pre>")
313+
println("<pre>")
316314
for (stmt in element.content) stmt.accept(this)
317-
if (shouldAddPreTag) println("</pre>")
315+
println("</pre>")
318316
}
317+
318+
override fun visit(element: CgCustomTagStatement) {
319+
if (element.content.all { it.isEmpty() }) return
320+
for (stmt in element.content) stmt.accept(this)
321+
}
322+
319323
override fun visit(element: CgDocCodeStmt) {
320324
if (element.isEmpty()) return
321325

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import org.utbot.framework.codegen.model.tree.CgDocClassLinkStmt
2222
import org.utbot.framework.codegen.model.tree.CgDocCodeStmt
2323
import org.utbot.framework.codegen.model.tree.CgDocMethodLinkStmt
2424
import org.utbot.framework.codegen.model.tree.CgDocPreTagStatement
25+
import org.utbot.framework.codegen.model.tree.CgCustomTagStatement
2526
import org.utbot.framework.codegen.model.tree.CgDocRegularStmt
2627
import org.utbot.framework.codegen.model.tree.CgDocumentationComment
2728
import org.utbot.framework.codegen.model.tree.CgElement
@@ -122,6 +123,7 @@ interface CgVisitor<R> {
122123

123124
// Comment statements
124125
fun visit(element: CgDocPreTagStatement): R
126+
fun visit(element: CgCustomTagStatement): R
125127
fun visit(element: CgDocCodeStmt): R
126128
fun visit(element: CgDocRegularStmt): R
127129
fun visit(element: CgDocClassLinkStmt): R

utbot-summary/src/main/kotlin/org/utbot/summary/comment/CustomJavaDocCommentBuilder.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.utbot.summary.comment
22

3-
import org.utbot.framework.plugin.api.DocPreTagStatement
3+
import org.utbot.framework.plugin.api.DocCustomTagStatement
44
import org.utbot.framework.plugin.api.DocRegularStmt
55
import org.utbot.framework.plugin.api.DocStatement
66
import org.utbot.framework.plugin.api.exceptionOrNull
@@ -46,7 +46,7 @@ class CustomJavaDocCommentBuilder(
4646
if (comment.throwsException.isNotEmpty())
4747
docStatementList += DocRegularStmt("@utbot.throwsException ${comment.throwsException}")
4848

49-
return listOf<DocStatement>(DocPreTagStatement(docStatementList))
49+
return listOf<DocStatement>(DocCustomTagStatement(docStatementList))
5050
}
5151

5252
private fun buildCustomJavaDocComment(currentMethod: SootMethod): CustomJavaDocComment {

0 commit comments

Comments
 (0)