Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e88bd65
Introduce custom plugin's JavaDoc tags #565
onewhl Jul 22, 2022
43c4cf0
Render UtBot custom JavaDoc tags correctly #565
onewhl Jul 25, 2022
760594f
Add an option to generate summaries using custom JavaDoc tags #565
onewhl Jul 26, 2022
050550f
Fill value of utbot.iterates tag #565
onewhl Jul 27, 2022
ca86976
Collect info about Invoke, Iterate, and Return sections #565
onewhl Jul 28, 2022
d77e739
Review fixes
onewhl Aug 1, 2022
6ae1157
Add unit tests for summaries with custom JavaDoc tags #565
onewhl Aug 2, 2022
100e3df
Fix after rebasing
onewhl Aug 3, 2022
8d4063b
Add summary tests for MinStack #565
onewhl Aug 3, 2022
6d01afe
Fix broken tests
onewhl Aug 4, 2022
d03ad76
Add <pre> tag only in case when custom javadoc tags are not used
onewhl Aug 4, 2022
74c5822
Use a full exception name instead of simple name to build inline link…
onewhl Aug 6, 2022
7e4aaf9
Minor refactoring
onewhl Aug 6, 2022
92eb15d
Minor refactoring: avoid code duplication
onewhl Aug 6, 2022
cf9b60f
Add DocCustomTagStatement and CgCustomTagStatement
onewhl Aug 6, 2022
9c14eb0
Refactored code to avoid code duplication
onewhl Aug 6, 2022
6dce850
Fix tests: add full name for classes
onewhl Aug 6, 2022
7800d33
Add JUnit extension to control USE_CUSTOM_TAGS setting
onewhl Aug 6, 2022
d003962
Move useCustomJavaDocTags to UtSettings, make useFuzzing true
onewhl Aug 7, 2022
f8e6764
Remove unused import and fix broken tests
onewhl Aug 7, 2022
321bf0d
Fix broken tests
onewhl Aug 8, 2022
a52fb20
Add comments, remove unused method
onewhl Aug 8, 2022
83f4e71
Review fixes: fixed formatting, removed redundant types
onewhl Aug 9, 2022
abe7ca6
Review fixes: fixed formatting, removed useless overriding methods
onewhl Aug 15, 2022
475cae5
Review fixes: extracted method, polished code
onewhl Aug 15, 2022
99b06ad
fix after rebasing
onewhl Aug 17, 2022
21a7035
fix after rebasing
onewhl Aug 23, 2022
4951b6f
review fixes
onewhl Aug 23, 2022
bd616a9
fix rendering after updating to idea 2022.1. now we don't need to gen…
onewhl Aug 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Collect info about Invoke, Iterate, and Return sections #565
  • Loading branch information
onewhl committed Aug 24, 2022
commit ca86976f0794d67a7d5221f3ab8a708ef8b84c60
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ package org.utbot.summary.comment
* Represents a set of plugin's custom JavaDoc tags.
*/
data class CustomJavaDocComment(
val classUnderTest: String,
val methodUnderTest: String,
val expectedResult: String?,
val actualResult: String?,
var executesCondition: String?,
var invokes: String?,
var iterates: String?,
var returnsFrom: String?,
var throwsException: String?
val classUnderTest: String = "",
val methodUnderTest: String = "",
val expectedResult: String = "",
val actualResult: String = "",
var executesCondition: List<String> = listOf(),
var invokes: List<String> = listOf(),
var iterates: List<String> = listOf(),
var returnsFrom: String = "",
var throwsException: String = ""
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,42 +23,51 @@ class CustomJavaDocCommentBuilder(

docStatementList += DocRegularStmt("@utbot.classUnderTest ${comment.classUnderTest}\n")
docStatementList += DocRegularStmt("@utbot.methodUnderTest ${comment.methodUnderTest}\n")
if (comment.expectedResult != null)

if (comment.expectedResult.isNotEmpty())
docStatementList += DocRegularStmt("@utbot.expectedResult ${comment.expectedResult}\n")
if (comment.actualResult != null)
if (comment.actualResult.isNotEmpty())
docStatementList += DocRegularStmt("@utbot.actualResult ${comment.actualResult}\n")
if (comment.executesCondition != null)
docStatementList += DocRegularStmt("@utbot.executesCondition ${comment.executesCondition}\n")
if (comment.invokes != null)
docStatementList += DocRegularStmt("@utbot.invokes ${comment.invokes}\n")
if (comment.iterates != null)
docStatementList += DocRegularStmt("@utbot.iterates ${comment.iterates}\n")
if (comment.returnsFrom != null)
if (comment.executesCondition.isNotEmpty()) {
val statement =
"@utbot.executesCondition ${comment.executesCondition.joinToString(separator = ",\n")}\n"
docStatementList += DocRegularStmt(statement)
}
if (comment.invokes.isNotEmpty()) {
val statement = "@utbot.invokes ${comment.invokes.joinToString(separator = ",\n")}\n"
docStatementList += DocRegularStmt(statement)
}
if (comment.iterates.isNotEmpty()) {
val statement = "@utbot.iterates ${comment.iterates.joinToString(separator = ",\n")}\n"
docStatementList += DocRegularStmt(statement)
}
if (comment.returnsFrom.isNotEmpty())
docStatementList += DocRegularStmt("@utbot.returnsFrom ${comment.returnsFrom}\n")
if (comment.throwsException != null)
if (comment.throwsException.isNotEmpty())
docStatementList += DocRegularStmt("@utbot.throwsException ${comment.throwsException}")

return listOf<DocStatement>(DocPreTagStatement(docStatementList))
}

private fun buildCustomJavaDocComment(currentMethod: SootMethod): CustomJavaDocComment {
val methodReference =
getMethodReference(currentMethod.declaringClass.name, currentMethod.name, currentMethod.parameterTypes)
val methodReference = getMethodReference(
currentMethod.declaringClass.name,
currentMethod.name,
currentMethod.parameterTypes
)
val classReference = getClassReference(currentMethod.declaringClass.javaStyleName)

val customJavaDocComment = CustomJavaDocComment(
classUnderTest = classReference,
methodUnderTest = methodReference,
expectedResult = null,
actualResult = null,
executesCondition = null,
invokes = null,
iterates = null,
returnsFrom = null,
throwsException = null
)

// build throws exception section
val rootSentenceBlock = SimpleSentenceBlock(stringTemplates = stringTemplates)
skippedIterations()
buildSentenceBlock(traceTag.rootStatementTag, rootSentenceBlock, currentMethod)
rootSentenceBlock.squashStmtText()

// builds Throws exception section
val thrownException = traceTag.result.exceptionOrNull()
val exceptionThrow: String? = if (thrownException == null) {
traceTag.result.exceptionOrNull()?.let { it::class.qualifiedName }
Comment thread
amandelpie marked this conversation as resolved.
Expand All @@ -67,40 +76,43 @@ class CustomJavaDocCommentBuilder(
val reason = findExceptionReason(currentMethod, thrownException)
"{@link $exceptionName} $reason"
}
customJavaDocComment.throwsException = exceptionThrow

val rootSentenceBlock = SimpleSentenceBlock(stringTemplates = stringTemplates)
skippedIterations()
buildSentenceBlock(traceTag.rootStatementTag, rootSentenceBlock, currentMethod)
if (exceptionThrow != null) {
customJavaDocComment.throwsException = exceptionThrow
}

// builds iterates section
// builds Iterates section
rootSentenceBlock.iterationSentenceBlocks.forEach { (loopDesc, sentenceBlocks) ->
customJavaDocComment.iterates = stringTemplates.iterationSentence.format(
customJavaDocComment.iterates += stringTemplates.iterationSentence.format(
stringTemplates.codeSentence.format(loopDesc),
numberOccurrencesToText(
sentenceBlocks.size
)
)
}

// build invokes, executes, and returns from sections
for (stmtDescription: StmtDescription in rootSentenceBlock.stmtTexts) {
when (stmtDescription.stmtType.name) {
//TODO: support multiple invokes (calls)
"Invoke" -> {
val info = stmtDescription.description
customJavaDocComment.invokes = "{@code $info}"
}
"Return" -> {
val info = stmtDescription.description
customJavaDocComment.returnsFrom = "{@code $info}"
}
//TODO: support multiple conditions
"Condition" -> {
val info = stmtDescription.description
customJavaDocComment.executesCondition = "{@code $info}"
// builds Invoke, Execute, Return sections
var currentBlock: SimpleSentenceBlock? = rootSentenceBlock
while (currentBlock != null) {
for (statement in currentBlock.stmtTexts) {
when (statement.stmtType) {
StmtType.Invoke -> {
val info = statement.description
customJavaDocComment.invokes += "{@code $info}"
}
StmtType.Condition -> {
val info = statement.description
customJavaDocComment.executesCondition += "{@code $info}"
}
StmtType.Return -> {
val info = statement.description
customJavaDocComment.returnsFrom = "{@code $info}"
}
else -> {
Comment thread
onewhl marked this conversation as resolved.
//TODO
}
}
}
currentBlock = currentBlock.nextBlock
}

return customJavaDocComment
Expand Down