Skip to content
Merged
Changes from 1 commit
Commits
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
Added a method and class references
  • Loading branch information
amandelpie committed Oct 5, 2022
commit 6ada057c721b362e10b2eb1ac923f5d74a7e2e29
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package org.utbot.summary.comment.customtags.fuzzer

import org.utbot.framework.plugin.api.ClassId
import org.utbot.framework.plugin.api.DocCustomTagStatement
import org.utbot.framework.plugin.api.DocStatement
import org.utbot.framework.plugin.api.UtExecutionResult
import org.utbot.fuzzer.FuzzedMethodDescription
import org.utbot.fuzzer.FuzzedValue
import org.utbot.summary.SummarySentenceConstants
import org.utbot.summary.SummarySentenceConstants.CARRIAGE_RETURN
import org.utbot.summary.comment.customtags.symbolic.CustomJavaDocTagProvider

/**
Expand All @@ -26,19 +29,45 @@ class CommentWithCustomTagForTestProducedByFuzzerBuilder(
}

private fun buildCustomJavaDocComment(): CommentWithCustomTagForTestProducedByFuzzer {
/*val methodReference = getMethodReference(
currentMethod.declaringClass.name,
currentMethod.name,
currentMethod.parameterTypes
val methodReference = getMethodReference(
methodDescription.packageName!! + "." + methodDescription.className!!,
methodDescription.compilableName!!,
methodDescription.parameters
)
val classReference = getClassReference(currentMethod.declaringClass.javaStyleName)*/
val classReference = getClassReference(methodDescription.packageName!! + "." +methodDescription.className!!)

val javaDocComment = CommentWithCustomTagForTestProducedByFuzzer(
classUnderTest = methodDescription.className!!,
methodUnderTest = methodDescription.name,
classUnderTest = classReference.replace(CARRIAGE_RETURN, ""),
methodUnderTest = methodReference.replace(CARRIAGE_RETURN, ""),
)


return javaDocComment
}

/**
* Returns a reference to the invoked method.
*
* It looks like {@link packageName.className#methodName(type1, type2)}.
*
* In case when an enclosing class in nested, we need to replace '$' with '.'
* to render the reference.
*/
private fun getMethodReference(className: String, methodName: String, methodParameterTypes: List<ClassId>): String {
val prettyClassName: String = className.replace("$", ".")

return if (methodParameterTypes.isEmpty()) {
"{@link $prettyClassName#$methodName()}"
} else {
val methodParametersAsString = methodParameterTypes.joinToString(",") { it.canonicalName }
"{@link $prettyClassName#$methodName($methodParametersAsString)}"
}
}

/**
* Returns a reference to the class.
* Replaces '$' with '.' in case a class is nested.
*/
private fun getClassReference(fullClassName: String): String {
return "{@link ${fullClassName.replace("$", ".")}}"
}
}