1
1
package org.utbot.summary.comment
2
2
3
3
import org.utbot.framework.plugin.api.DocCustomTagStatement
4
- import org.utbot.framework.plugin.api.DocRegularStmt
5
4
import org.utbot.framework.plugin.api.DocStatement
6
5
import org.utbot.framework.plugin.api.exceptionOrNull
7
6
import org.utbot.summary.ast.JimpleToASTMap
8
7
import org.utbot.summary.tag.TraceTagWithoutExecution
9
8
import soot.SootMethod
10
9
11
- // TODO: polish code
12
10
class CustomJavaDocCommentBuilder (
13
11
traceTag : TraceTagWithoutExecution ,
14
12
sootToAST : MutableMap <SootMethod , JimpleToASTMap >
@@ -19,33 +17,8 @@ class CustomJavaDocCommentBuilder(
19
17
*/
20
18
fun buildDocStatements (method : SootMethod ): List <DocStatement > {
21
19
val comment: CustomJavaDocComment = buildCustomJavaDocComment(method)
22
- val docStatementList = mutableListOf<DocStatement >()
23
-
24
- docStatementList + = DocRegularStmt (" @utbot.classUnderTest ${comment.classUnderTest} \n " )
25
- docStatementList + = DocRegularStmt (" @utbot.methodUnderTest ${comment.methodUnderTest} \n " )
26
-
27
- if (comment.expectedResult.isNotEmpty())
28
- docStatementList + = DocRegularStmt (" @utbot.expectedResult ${comment.expectedResult} \n " )
29
- if (comment.actualResult.isNotEmpty())
30
- docStatementList + = DocRegularStmt (" @utbot.actualResult ${comment.actualResult} \n " )
31
- if (comment.executesCondition.isNotEmpty()) {
32
- val statement =
33
- " @utbot.executesCondition ${comment.executesCondition.joinToString(separator = " ,\n " )} \n "
34
- docStatementList + = DocRegularStmt (statement)
35
- }
36
- if (comment.invokes.isNotEmpty()) {
37
- val statement = " @utbot.invokes ${comment.invokes.joinToString(separator = " ,\n " )} \n "
38
- docStatementList + = DocRegularStmt (statement)
39
- }
40
- if (comment.iterates.isNotEmpty()) {
41
- val statement = " @utbot.iterates ${comment.iterates.joinToString(separator = " ,\n " )} \n "
42
- docStatementList + = DocRegularStmt (statement)
43
- }
44
- if (comment.returnsFrom.isNotEmpty())
45
- docStatementList + = DocRegularStmt (" @utbot.returnsFrom ${comment.returnsFrom} \n " )
46
- if (comment.throwsException.isNotEmpty())
47
- docStatementList + = DocRegularStmt (" @utbot.throwsException ${comment.throwsException} " )
48
-
20
+ val docStatementList =
21
+ CustomJavaDocTagProvider ().getPluginCustomTags().mapNotNull { it.generateDocStatement(comment) }
49
22
return listOf<DocStatement >(DocCustomTagStatement (docStatementList))
50
23
}
51
24
@@ -95,20 +68,11 @@ class CustomJavaDocCommentBuilder(
95
68
while (currentBlock != null ) {
96
69
for (statement in currentBlock.stmtTexts) {
97
70
when (statement.stmtType) {
98
- StmtType .Invoke -> {
99
- val info = statement.description
100
- customJavaDocComment.invokes + = " {@code $info }"
101
- }
102
- StmtType .Condition -> {
103
- val info = statement.description
104
- customJavaDocComment.executesCondition + = " {@code $info }"
105
- }
106
- StmtType .Return -> {
107
- val info = statement.description
108
- customJavaDocComment.returnsFrom = " {@code $info }"
109
- }
71
+ StmtType .Invoke -> customJavaDocComment.invokes + = " {@code ${statement.description} }"
72
+ StmtType .Condition -> customJavaDocComment.executesCondition + = " {@code ${statement.description} }"
73
+ StmtType .Return -> customJavaDocComment.returnsFrom = " {@code ${statement.description} }"
110
74
else -> {
111
- // TODO
75
+ // TODO: do we need to handle others?
112
76
}
113
77
}
114
78
}
0 commit comments