@@ -42,7 +42,21 @@ open class SimpleCommentBuilder(
42
42
*/
43
43
open fun buildString (currentMethod : SootMethod ): String {
44
44
val root = SimpleSentenceBlock (stringTemplates = stringTemplates)
45
+ buildThrownExceptionInfo(root, currentMethod)
46
+ skippedIterations()
47
+ buildSentenceBlock(traceTag.rootStatementTag, root, currentMethod)
48
+ var sentence = toSentence(root)
49
+ if (sentence.isEmpty()) return genWarnNotification()
50
+ sentence = splitLongSentence(sentence)
51
+ sentence = lastCommaToDot(sentence)
45
52
53
+ return " <pre>\n $sentence </pre>" .replace(CARRIAGE_RETURN , " " )
54
+ }
55
+
56
+ private fun buildThrownExceptionInfo (
57
+ root : SimpleSentenceBlock ,
58
+ currentMethod : SootMethod
59
+ ) {
46
60
val thrownException = traceTag.result.exceptionOrNull()
47
61
if (thrownException == null ) {
48
62
root.exceptionThrow = traceTag.result.exceptionOrNull()?.let { it::class .qualifiedName }
@@ -51,14 +65,6 @@ open class SimpleCommentBuilder(
51
65
val reason = findExceptionReason(currentMethod, thrownException)
52
66
root.exceptionThrow = " $exceptionName $reason "
53
67
}
54
- skippedIterations()
55
- buildSentenceBlock(traceTag.rootStatementTag, root, currentMethod)
56
- var sentence = toSentence(root)
57
- if (sentence.isEmpty()) return genWarnNotification()
58
- sentence = splitLongSentence(sentence)
59
- sentence = lastCommaToDot(sentence)
60
-
61
- return " <pre>\n $sentence </pre>" .replace(CARRIAGE_RETURN , " " )
62
68
}
63
69
64
70
/* *
@@ -79,15 +85,7 @@ open class SimpleCommentBuilder(
79
85
80
86
private fun buildSentenceBlock (currentMethod : SootMethod ): SimpleSentenceBlock {
81
87
val rootSentenceBlock = SimpleSentenceBlock (stringTemplates = stringTemplates)
82
-
83
- val thrownException = traceTag.result.exceptionOrNull()
84
- if (thrownException == null ) {
85
- rootSentenceBlock.exceptionThrow = traceTag.result.exceptionOrNull()?.let { it::class .qualifiedName }
86
- } else {
87
- val exceptionName = thrownException.javaClass.simpleName
88
- val reason = findExceptionReason(currentMethod, thrownException)
89
- rootSentenceBlock.exceptionThrow = " $exceptionName $reason "
90
- }
88
+ buildThrownExceptionInfo(rootSentenceBlock, currentMethod)
91
89
skippedIterations()
92
90
buildSentenceBlock(traceTag.rootStatementTag, rootSentenceBlock, currentMethod)
93
91
return rootSentenceBlock
0 commit comments