Skip to content

Commit d35dad5

Browse files
onewhlAbdullinAM
authored andcommittedOct 17, 2022
Fix rendering for different IDE versions (UnitTestBot#1087)
* Fix rendering for different IDE versions * add info about IDE version for each case
1 parent fa5ca86 commit d35dad5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed
 

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,20 @@ class UtDocumentationProvider : JavaDocumentationProvider() {
3737
docComment: PsiDocComment,
3838
comment: PsiDocCommentBase
3939
): String? {
40-
// add UTBot sections with custom tags.
4140
val utJavaDocInfoGenerator = UtJavaDocInfoGenerator()
42-
return if (baseJavaDocInfo != null && baseJavaDocInfo.contains("utbot")) {
41+
// case 1 (2022.2): IDE successfully parsed comment with plugin's custom tags,
42+
// and we only need to replace tags names with their messages.
43+
return if (baseJavaDocInfo != null && baseJavaDocInfo.contains("@utbot")) {
44+
val finalJavaDoc = replaceTagNamesWithMessages(baseJavaDocInfo)
45+
JavaDocExternalFilter.filterInternalDocInfo(finalJavaDoc)
46+
// case 2 (2022.1 and older): IDE failed to parse plugin's tags, and we need to add them on our own.
47+
} else if (baseJavaDocInfo != null && comment.text.contains("@utbot")) {
4348
val javaDocInfoWithUtSections =
4449
utJavaDocInfoGenerator.addUtBotSpecificSectionsToJavaDoc(docComment)
4550
val finalJavaDoc = replaceTagNamesWithMessages(javaDocInfoWithUtSections)
4651
JavaDocExternalFilter.filterInternalDocInfo(finalJavaDoc)
4752
} else {
53+
// case 3: comment doesn't contain plugin's tags, so IDE can parse it on its own.
4854
super.generateRenderedDoc(comment)
4955
}
5056
}

0 commit comments

Comments
 (0)
Please sign in to comment.