Skip to content

Commit 464acbe

Browse files
committed
Minor refactoring
1 parent 5288e56 commit 464acbe

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/javadoc/UtCustomJavaDocTagProvider.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import com.intellij.psi.javadoc.PsiDocTagValue
1111
* Provides plugin's custom JavaDoc tags to make test summaries structured.
1212
*/
1313
class UtCustomJavaDocTagProvider : CustomJavadocTagProvider {
14-
override fun getSupportedTags(): List<JavadocTagInfo> =
14+
// The tags' order is important.
15+
override fun getSupportedTags(): List<UtCustomTag> =
1516
listOf(
1617
UtCustomTag.ClassUnderTest,
1718
UtCustomTag.MethodUnderTest,
@@ -24,6 +25,7 @@ class UtCustomJavaDocTagProvider : CustomJavadocTagProvider {
2425
UtCustomTag.ThrowsException,
2526
)
2627

28+
//TODO: move it to another module to avoid duplication
2729
sealed class UtCustomTag(private val name: String, private val message: String) : JavadocTagInfo {
2830
override fun getName(): String = name
2931

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/javadoc/UtJavaDocInfoGenerator.kt

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,10 @@ class UtJavaDocInfoGenerator {
2828
*/
2929
fun addUtBotSpecificSectionsToJavaDoc(javadoc: String?, comment: PsiDocComment): String {
3030
val builder: StringBuilder = StringBuilder(javadoc)
31-
generateUtTagSection(builder, comment, UtCustomJavaDocTagProvider.UtCustomTag.ClassUnderTest)
32-
generateUtTagSection(builder, comment, UtCustomJavaDocTagProvider.UtCustomTag.MethodUnderTest)
33-
generateUtTagSection(builder, comment, UtCustomJavaDocTagProvider.UtCustomTag.Invokes)
34-
generateUtTagSection(builder, comment, UtCustomJavaDocTagProvider.UtCustomTag.Executes)
35-
generateUtTagSection(builder, comment, UtCustomJavaDocTagProvider.UtCustomTag.Iterates)
36-
generateUtTagSection(builder, comment, UtCustomJavaDocTagProvider.UtCustomTag.ExpectedResult)
37-
generateUtTagSection(builder, comment, UtCustomJavaDocTagProvider.UtCustomTag.ActualResult)
38-
generateUtTagSection(builder, comment, UtCustomJavaDocTagProvider.UtCustomTag.ReturnsFrom)
39-
generateUtTagSection(builder, comment, UtCustomJavaDocTagProvider.UtCustomTag.ThrowsException)
31+
val docTagProvider = UtCustomJavaDocTagProvider()
32+
docTagProvider.supportedTags.forEach {
33+
generateUtTagSection(builder, comment, it)
34+
}
4035
return builder.toString()
4136
}
4237

@@ -50,7 +45,7 @@ class UtJavaDocInfoGenerator {
5045
) {
5146
if (comment != null) {
5247
val tag = comment.findTagByName(utTag.name) ?: return
53-
startHeaderSection(builder, utTag.getMessage())?.append("<p>")
48+
startHeaderSection(builder, utTag.getMessage()).append("<p>")
5449
val sectionContent = buildString {
5550
generateValue(this, tag.dataElements)
5651
this.trim { it <= ' ' }
@@ -60,7 +55,7 @@ class UtJavaDocInfoGenerator {
6055
}
6156
}
6257

63-
private fun startHeaderSection(builder: StringBuilder, message: String): StringBuilder? {
58+
private fun startHeaderSection(builder: StringBuilder, message: String): StringBuilder {
6459
return builder.append(DocumentationMarkup.SECTION_HEADER_START)
6560
.append(message)
6661
.append(MESSAGE_SEPARATOR)

0 commit comments

Comments
 (0)