Skip to content

Commit

Permalink
Fix rendering for different IDE versions (#1087)
Browse files Browse the repository at this point in the history
* Fix rendering for different IDE versions

* add info about IDE version for each case
  • Loading branch information
onewhl authored Oct 4, 2022
1 parent da1dde7 commit c053c63
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,20 @@ class UtDocumentationProvider : JavaDocumentationProvider() {
docComment: PsiDocComment,
comment: PsiDocCommentBase
): String? {
// add UTBot sections with custom tags.
val utJavaDocInfoGenerator = UtJavaDocInfoGenerator()
return if (baseJavaDocInfo != null && baseJavaDocInfo.contains("utbot")) {
// case 1 (2022.2): IDE successfully parsed comment with plugin's custom tags,
// and we only need to replace tags names with their messages.
return if (baseJavaDocInfo != null && baseJavaDocInfo.contains("@utbot")) {
val finalJavaDoc = replaceTagNamesWithMessages(baseJavaDocInfo)
JavaDocExternalFilter.filterInternalDocInfo(finalJavaDoc)
// case 2 (2022.1 and older): IDE failed to parse plugin's tags, and we need to add them on our own.
} else if (baseJavaDocInfo != null && comment.text.contains("@utbot")) {
val javaDocInfoWithUtSections =
utJavaDocInfoGenerator.addUtBotSpecificSectionsToJavaDoc(docComment)
val finalJavaDoc = replaceTagNamesWithMessages(javaDocInfoWithUtSections)
JavaDocExternalFilter.filterInternalDocInfo(finalJavaDoc)
} else {
// case 3: comment doesn't contain plugin's tags, so IDE can parse it on its own.
super.generateRenderedDoc(comment)
}
}
Expand Down

0 comments on commit c053c63

Please sign in to comment.