@@ -42,7 +42,21 @@ open class SimpleCommentBuilder(
4242 */
4343 open fun buildString (currentMethod : SootMethod ): String {
4444 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)
4552
53+ return " <pre>\n $sentence </pre>" .replace(CARRIAGE_RETURN , " " )
54+ }
55+
56+ private fun buildThrownExceptionInfo (
57+ root : SimpleSentenceBlock ,
58+ currentMethod : SootMethod
59+ ) {
4660 val thrownException = traceTag.result.exceptionOrNull()
4761 if (thrownException == null ) {
4862 root.exceptionThrow = traceTag.result.exceptionOrNull()?.let { it::class .qualifiedName }
@@ -51,14 +65,6 @@ open class SimpleCommentBuilder(
5165 val reason = findExceptionReason(currentMethod, thrownException)
5266 root.exceptionThrow = " $exceptionName $reason "
5367 }
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 , " " )
6268 }
6369
6470 /* *
@@ -79,15 +85,7 @@ open class SimpleCommentBuilder(
7985
8086 private fun buildSentenceBlock (currentMethod : SootMethod ): SimpleSentenceBlock {
8187 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)
9189 skippedIterations()
9290 buildSentenceBlock(traceTag.rootStatementTag, rootSentenceBlock, currentMethod)
9391 return rootSentenceBlock
0 commit comments