Skip to content

Commit 67b0874

Browse files
committed
Add DocCustomTagStatement and CgCustomTagStatement
1 parent 66f97e5 commit 67b0874

File tree

5 files changed

+36
-8
lines changed

5 files changed

+36
-8
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import org.utbot.framework.plugin.api.util.isPrimitive
2828
import org.utbot.framework.plugin.api.util.jClass
2929
import org.utbot.framework.plugin.api.util.longClassId
3030
import org.utbot.framework.plugin.api.util.method
31-
import org.utbot.framework.plugin.api.util.objectClassId
3231
import org.utbot.framework.plugin.api.util.primitiveTypeJvmNameOrNull
3332
import org.utbot.framework.plugin.api.util.safeJField
3433
import org.utbot.framework.plugin.api.util.shortClassId
@@ -1243,6 +1242,14 @@ class DocPreTagStatement(content: List<DocStatement>) : DocTagStatement(content)
12431242
override fun hashCode(): Int = content.hashCode()
12441243
}
12451244

1245+
class DocCustomTagStatement(content: List<DocStatement>) : DocTagStatement(content) {
1246+
override fun toString(): String = content.joinToString(separator = "")
1247+
1248+
override fun equals(other: Any?): Boolean =
1249+
if (other is DocCustomTagStatement) this.hashCode() == other.hashCode() else false
1250+
1251+
override fun hashCode(): Int = content.hashCode()
1252+
}
12461253

12471254
open class DocClassLinkStmt(val className: String) : DocStatement() {
12481255
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
@@ -51,6 +52,7 @@ interface CgElement {
5152
is CgMultilineComment -> visit(element)
5253
is CgDocumentationComment -> visit(element)
5354
is CgDocPreTagStatement -> visit(element)
55+
is CgCustomTagStatement -> visit(element)
5456
is CgDocCodeStmt -> visit(element)
5557
is CgDocRegularStmt -> visit(element)
5658
is CgDocClassLinkStmt -> visit(element)
@@ -330,6 +332,15 @@ class CgDocPreTagStatement(content: List<CgDocStatement>) : CgDocTagStatement(co
330332
override fun hashCode(): Int = content.hashCode()
331333
}
332334

335+
class CgCustomTagStatement(content: List<CgDocStatement>) : CgDocTagStatement(content) {
336+
override fun equals(other: Any?): Boolean =
337+
if (other is CgCustomTagStatement) {
338+
this.hashCode() == other.hashCode()
339+
} else false
340+
341+
override fun hashCode(): Int = content.hashCode()
342+
}
343+
333344
class CgDocCodeStmt(val stmt: String) : CgDocStatement() {
334345
override fun isEmpty(): Boolean = stmt.isEmpty()
335346

@@ -374,6 +385,10 @@ fun convertDocToCg(stmt: DocStatement): CgDocStatement {
374385
val stmts = stmt.content.map { convertDocToCg(it) }
375386
CgDocPreTagStatement(content = stmts)
376387
}
388+
is DocCustomTagStatement -> {
389+
val stmts = stmt.content.map { convertDocToCg(it) }
390+
CgCustomTagStatement(content = stmts)
391+
}
377392
is DocRegularStmt -> CgDocRegularStmt(stmt = stmt.stmt)
378393
is DocClassLinkStmt -> CgDocClassLinkStmt(className = stmt.className)
379394
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
@@ -91,7 +92,6 @@ import org.utbot.framework.plugin.api.util.isArray
9192
import org.utbot.framework.plugin.api.util.isRefType
9293
import org.utbot.framework.plugin.api.util.longClassId
9394
import org.utbot.framework.plugin.api.util.shortClassId
94-
import org.utbot.summary.UtSummarySettings
9595

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

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
@@ -121,6 +122,7 @@ interface CgVisitor<R> {
121122

122123
// Comment statements
123124
fun visit(element: CgDocPreTagStatement): R
125+
fun visit(element: CgCustomTagStatement): R
124126
fun visit(element: CgDocCodeStmt): R
125127
fun visit(element: CgDocRegularStmt): R
126128
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)