Skip to content

Commit 6ada057

Browse files
committed
Added a method and class references
1 parent b92b198 commit 6ada057

1 file changed

Lines changed: 37 additions & 8 deletions

File tree

utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/fuzzer/CommentWithCustomTagForTestProducedByFuzzerBuilder.kt

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package org.utbot.summary.comment.customtags.fuzzer
22

3+
import org.utbot.framework.plugin.api.ClassId
34
import org.utbot.framework.plugin.api.DocCustomTagStatement
45
import org.utbot.framework.plugin.api.DocStatement
56
import org.utbot.framework.plugin.api.UtExecutionResult
67
import org.utbot.fuzzer.FuzzedMethodDescription
78
import org.utbot.fuzzer.FuzzedValue
9+
import org.utbot.summary.SummarySentenceConstants
10+
import org.utbot.summary.SummarySentenceConstants.CARRIAGE_RETURN
811
import 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

Comments
 (0)