11package org.utbot.summary.comment.customtags.fuzzer
22
3+ import org.utbot.framework.plugin.api.ClassId
34import org.utbot.framework.plugin.api.DocCustomTagStatement
45import org.utbot.framework.plugin.api.DocStatement
56import org.utbot.framework.plugin.api.UtExecutionResult
67import org.utbot.fuzzer.FuzzedMethodDescription
78import org.utbot.fuzzer.FuzzedValue
9+ import org.utbot.summary.SummarySentenceConstants
10+ import org.utbot.summary.SummarySentenceConstants.CARRIAGE_RETURN
811import org.utbot.summary.comment.customtags.symbolic.CustomJavaDocTagProvider
912
1013/* *
@@ -26,19 +29,45 @@ class CommentWithCustomTagForTestProducedByFuzzerBuilder(
2629 }
2730
2831 private fun buildCustomJavaDocComment (): CommentWithCustomTagForTestProducedByFuzzer {
29- /* val methodReference = getMethodReference(
30- currentMethod.declaringClass.name ,
31- currentMethod.name ,
32- currentMethod.parameterTypes
32+ val methodReference = getMethodReference(
33+ methodDescription.packageName !! + " . " + methodDescription.className !! ,
34+ methodDescription.compilableName !! ,
35+ methodDescription.parameters
3336 )
34- val classReference = getClassReference(currentMethod.declaringClass.javaStyleName) */
37+ val classReference = getClassReference(methodDescription.packageName !! + " . " + methodDescription.className !! )
3538
3639 val javaDocComment = CommentWithCustomTagForTestProducedByFuzzer (
37- classUnderTest = methodDescription.className !! ,
38- methodUnderTest = methodDescription.name ,
40+ classUnderTest = classReference.replace( CARRIAGE_RETURN , " " ) ,
41+ methodUnderTest = methodReference.replace( CARRIAGE_RETURN , " " ) ,
3942 )
4043
41-
4244 return javaDocComment
4345 }
46+
47+ /* *
48+ * Returns a reference to the invoked method.
49+ *
50+ * It looks like {@link packageName.className#methodName(type1, type2)}.
51+ *
52+ * In case when an enclosing class in nested, we need to replace '$' with '.'
53+ * to render the reference.
54+ */
55+ private fun getMethodReference (className : String , methodName : String , methodParameterTypes : List <ClassId >): String {
56+ val prettyClassName: String = className.replace(" $" , " ." )
57+
58+ return if (methodParameterTypes.isEmpty()) {
59+ " {@link $prettyClassName #$methodName ()}"
60+ } else {
61+ val methodParametersAsString = methodParameterTypes.joinToString(" ," ) { it.canonicalName }
62+ " {@link $prettyClassName #$methodName ($methodParametersAsString )}"
63+ }
64+ }
65+
66+ /* *
67+ * Returns a reference to the class.
68+ * Replaces '$' with '.' in case a class is nested.
69+ */
70+ private fun getClassReference (fullClassName : String ): String {
71+ return " {@link ${fullClassName.replace(" $" , " ." )} }"
72+ }
4473}
0 commit comments