Skip to content

Commit 4600a4a

Browse files
committed
Renaming and refactoring
1 parent 365e0e4 commit 4600a4a

File tree

7 files changed

+43
-43
lines changed

7 files changed

+43
-43
lines changed

utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/fuzzer/SimpleCommentForTestProducedByFuzzerBuilder.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@ class SimpleCommentForTestProducedByFuzzerBuilder(
3030
methodName,
3131
methodDescription.parameters,
3232
false
33-
).replace(SummarySentenceConstants.CARRIAGE_RETURN, "")
34-
35-
val classReference = getClassReference(fullClassName).replace(SummarySentenceConstants.CARRIAGE_RETURN, "")
33+
)
3634

35+
val classReference = getClassReference(fullClassName)
3736

3837
val docStatements = mutableListOf<DocStatement>()
3938
docStatements.add(DocRegularStmt("Class under test: $classReference$NEW_LINE"))

utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/symbolic/SimpleCommentBuilder.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import org.utbot.framework.plugin.api.exceptionOrNull
1616
import org.utbot.summary.AbstractTextBuilder
1717
import org.utbot.summary.SummarySentenceConstants.CARRIAGE_RETURN
1818
import org.utbot.summary.ast.JimpleToASTMap
19-
import org.utbot.summary.comment.customtags.getMethodReference
19+
import org.utbot.summary.comment.customtags.getMethodReferenceForSymbolicTest
2020
import org.utbot.summary.tag.BasicTypeTag
2121
import org.utbot.summary.tag.CallOrderTag
2222
import org.utbot.summary.tag.StatementTag
@@ -196,7 +196,7 @@ open class SimpleCommentBuilder(
196196
if (!sentenceInvoke.isEmpty()) {
197197
sentenceBlock.invokeSentenceBlock =
198198
Pair(
199-
getMethodReference(className, methodName, methodParameterTypes, invokeSootMethod.isPrivate),
199+
getMethodReferenceForSymbolicTest(className, methodName, methodParameterTypes, invokeSootMethod.isPrivate),
200200
sentenceInvoke
201201
)
202202
createNextBlock = true
@@ -333,7 +333,7 @@ open class SimpleCommentBuilder(
333333
sentenceBlock.stmtTexts.add(
334334
StmtDescription(
335335
StmtType.Invoke,
336-
getMethodReference(className, methodName, methodParameterTypes, isPrivate),
336+
getMethodReferenceForSymbolicTest(className, methodName, methodParameterTypes, isPrivate),
337337
frequency
338338
)
339339
)

utbot-summary/src/main/kotlin/org/utbot/summary/comment/cluster/SymbolicExecutionClusterCommentBuilder.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import org.utbot.framework.plugin.api.DocStatement
77
import org.utbot.summary.SummarySentenceConstants.CARRIAGE_RETURN
88
import org.utbot.summary.ast.JimpleToASTMap
99
import org.utbot.summary.comment.*
10-
import org.utbot.summary.comment.customtags.getMethodReference
10+
import org.utbot.summary.comment.customtags.getMethodReferenceForSymbolicTest
1111
import org.utbot.summary.tag.BasicTypeTag
1212
import org.utbot.summary.tag.CallOrderTag
1313
import org.utbot.summary.tag.StatementTag
@@ -42,7 +42,7 @@ class SymbolicExecutionClusterCommentBuilder(
4242
sentence = splitLongSentence(sentence)
4343
sentence = lastCommaToDot(sentence)
4444

45-
return "<pre>\n$sentence</pre>".replace(CARRIAGE_RETURN, "")
45+
return "<pre>\n$sentence</pre>".replace(CARRIAGE_RETURN, EMPTY_STRING)
4646
}
4747

4848
override fun buildDocStmts(currentMethod: SootMethod): List<DocStatement> {
@@ -98,7 +98,7 @@ class SymbolicExecutionClusterCommentBuilder(
9898
if (!sentenceInvoke.isEmpty()) {
9999
sentenceBlock.invokeSentenceBlock =
100100
Pair(
101-
getMethodReference(className, methodName, methodParameterTypes, isPrivate),
101+
getMethodReferenceForSymbolicTest(className, methodName, methodParameterTypes, isPrivate),
102102
sentenceInvoke
103103
)
104104
createNextBlock = true
Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package org.utbot.summary.comment.customtags
22

33
import org.utbot.framework.plugin.api.ClassId
4+
import org.utbot.summary.SummarySentenceConstants
5+
import org.utbot.summary.comment.EMPTY_STRING
46
import soot.Type
57

68
/**
@@ -12,34 +14,15 @@ import soot.Type
1214
* In case when an enclosing class in nested, we need to replace '$' with '.'
1315
* to render the reference.
1416
*/
15-
fun getMethodReference(
17+
fun getMethodReferenceForSymbolicTest(
1618
className: String,
1719
methodName: String,
1820
methodParameterTypes: List<Type>,
1921
isPrivate: Boolean
2022
): String {
21-
val prettyClassName: String = className.replace("$", ".")
22-
23-
val text = if (methodParameterTypes.isEmpty()) {
24-
"$prettyClassName#$methodName()"
25-
} else {
26-
val methodParametersAsString = methodParameterTypes.joinToString(",")
27-
"$prettyClassName#$methodName($methodParametersAsString)"
28-
}
29-
30-
return if (isPrivate) {
31-
text
32-
} else {
33-
"{@link $text}"
34-
}
35-
}
23+
val methodParametersAsString = if (methodParameterTypes.isNotEmpty()) methodParameterTypes.joinToString(",") else EMPTY_STRING
3624

37-
/**
38-
* Returns a reference to the class.
39-
* Replaces '$' with '.' in case a class is nested.
40-
*/
41-
fun getClassReference(fullClassName: String): String {
42-
return "{@link ${fullClassName.replace("$", ".")}}"
25+
return formMethodReferenceForJavaDoc(className, methodName, methodParametersAsString, isPrivate)
4326
}
4427

4528
/**
@@ -51,12 +34,23 @@ fun getClassReference(fullClassName: String): String {
5134
* to render the reference.
5235
*/
5336
fun getMethodReferenceForFuzzingTest(className: String, methodName: String, methodParameterTypes: List<ClassId>, isPrivate: Boolean): String {
37+
val methodParametersAsString = if (methodParameterTypes.isNotEmpty()) methodParameterTypes.joinToString(",") { it.canonicalName } else EMPTY_STRING
38+
39+
return formMethodReferenceForJavaDoc(className, methodName, methodParametersAsString, isPrivate).replace(
40+
SummarySentenceConstants.CARRIAGE_RETURN, EMPTY_STRING)
41+
}
42+
43+
private fun formMethodReferenceForJavaDoc(
44+
className: String,
45+
methodName: String,
46+
methodParametersAsString: String,
47+
isPrivate: Boolean
48+
): String {
5449
val prettyClassName: String = className.replace("$", ".")
5550

56-
val text = if (methodParameterTypes.isEmpty()) {
51+
val text = if (methodParametersAsString == "") {
5752
"$prettyClassName#$methodName()"
5853
} else {
59-
val methodParametersAsString = methodParameterTypes.joinToString(",") { it.canonicalName }
6054
"$prettyClassName#$methodName($methodParametersAsString)"
6155
}
6256

@@ -65,4 +59,12 @@ fun getMethodReferenceForFuzzingTest(className: String, methodName: String, meth
6559
} else {
6660
"{@link $text}"
6761
}
62+
}
63+
64+
/**
65+
* Returns a reference to the class.
66+
* Replaces '$' with '.' in case a class is nested.
67+
*/
68+
fun getClassReference(fullClassName: String): String {
69+
return "{@link ${fullClassName.replace("$", ".")}}".replace(SummarySentenceConstants.CARRIAGE_RETURN, EMPTY_STRING)
6870
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ class CommentWithCustomTagForTestProducedByFuzzerBuilder(
4242
methodName,
4343
methodDescription.parameters,
4444
false
45-
).replace(CARRIAGE_RETURN, "")
45+
)
4646

47-
val classReference = getClassReference(fullClassName).replace(CARRIAGE_RETURN, "")
47+
val classReference = getClassReference(fullClassName)
4848

4949
CommentWithCustomTagForTestProducedByFuzzer(
5050
classUnderTest = classReference,

utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocCommentBuilder.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import org.utbot.summary.SummarySentenceConstants.CARRIAGE_RETURN
77
import org.utbot.summary.ast.JimpleToASTMap
88
import org.utbot.summary.comment.*
99
import org.utbot.summary.comment.customtags.getClassReference
10-
import org.utbot.summary.comment.customtags.getMethodReference
10+
import org.utbot.summary.comment.customtags.getMethodReferenceForSymbolicTest
1111
import org.utbot.summary.tag.TraceTagWithoutExecution
1212
import soot.SootMethod
1313

@@ -30,7 +30,7 @@ class CustomJavaDocCommentBuilder(
3030
}
3131

3232
private fun buildCustomJavaDocComment(currentMethod: SootMethod): CustomJavaDocComment {
33-
val methodReference = getMethodReference(
33+
val methodReference = getMethodReferenceForSymbolicTest(
3434
currentMethod.declaringClass.name,
3535
currentMethod.name,
3636
currentMethod.parameterTypes,
@@ -39,8 +39,8 @@ class CustomJavaDocCommentBuilder(
3939
val classReference = getClassReference(currentMethod.declaringClass.javaStyleName)
4040

4141
val comment = CustomJavaDocComment(
42-
classUnderTest = classReference.replace(CARRIAGE_RETURN, ""),
43-
methodUnderTest = methodReference.replace(CARRIAGE_RETURN, ""),
42+
classUnderTest = classReference,
43+
methodUnderTest = methodReference,
4444
)
4545

4646
val rootSentenceBlock = SimpleSentenceBlock(stringTemplates = stringTemplates)

utbot-summary/src/test/kotlin/org/utbot/summary/comment/SimpleCommentBuilderTest.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import org.mockito.Mockito.`when`
99
import org.utbot.framework.plugin.api.Step
1010
import org.utbot.framework.plugin.api.UtOverflowFailure
1111
import org.utbot.summary.ast.JimpleToASTMap
12-
import org.utbot.summary.comment.customtags.getMethodReference
12+
import org.utbot.summary.comment.customtags.getMethodReferenceForSymbolicTest
1313
import org.utbot.summary.tag.StatementTag
1414
import org.utbot.summary.tag.TraceTag
1515
import soot.SootMethod
@@ -67,17 +67,16 @@ class SimpleCommentBuilderTest {
6767

6868
@Test
6969
fun `builds inline link for method`() {
70-
val methodReference = getMethodReference("org.utbot.ClassName", "methodName", listOf(), false)
70+
val methodReference = getMethodReferenceForSymbolicTest("org.utbot.ClassName", "methodName", listOf(), false)
7171
val expectedMethodReference = "{@link org.utbot.ClassName#methodName()}"
7272
assertEquals(methodReference, expectedMethodReference)
7373
}
7474

7575
@Test
7676
fun `builds inline link for method in nested class`() {
7777
val methodReference =
78-
getMethodReference("org.utbot.ClassName\$NestedClassName", "methodName", listOf(), false)
78+
getMethodReferenceForSymbolicTest("org.utbot.ClassName\$NestedClassName", "methodName", listOf(), false)
7979
val expectedMethodReference = "{@link org.utbot.ClassName.NestedClassName#methodName()}"
8080
assertEquals(methodReference, expectedMethodReference)
8181
}
82-
8382
}

0 commit comments

Comments
 (0)