Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e88bd65
Introduce custom plugin's JavaDoc tags #565
onewhl Jul 22, 2022
43c4cf0
Render UtBot custom JavaDoc tags correctly #565
onewhl Jul 25, 2022
760594f
Add an option to generate summaries using custom JavaDoc tags #565
onewhl Jul 26, 2022
050550f
Fill value of utbot.iterates tag #565
onewhl Jul 27, 2022
ca86976
Collect info about Invoke, Iterate, and Return sections #565
onewhl Jul 28, 2022
d77e739
Review fixes
onewhl Aug 1, 2022
6ae1157
Add unit tests for summaries with custom JavaDoc tags #565
onewhl Aug 2, 2022
100e3df
Fix after rebasing
onewhl Aug 3, 2022
8d4063b
Add summary tests for MinStack #565
onewhl Aug 3, 2022
6d01afe
Fix broken tests
onewhl Aug 4, 2022
d03ad76
Add <pre> tag only in case when custom javadoc tags are not used
onewhl Aug 4, 2022
74c5822
Use a full exception name instead of simple name to build inline link…
onewhl Aug 6, 2022
7e4aaf9
Minor refactoring
onewhl Aug 6, 2022
92eb15d
Minor refactoring: avoid code duplication
onewhl Aug 6, 2022
cf9b60f
Add DocCustomTagStatement and CgCustomTagStatement
onewhl Aug 6, 2022
9c14eb0
Refactored code to avoid code duplication
onewhl Aug 6, 2022
6dce850
Fix tests: add full name for classes
onewhl Aug 6, 2022
7800d33
Add JUnit extension to control USE_CUSTOM_TAGS setting
onewhl Aug 6, 2022
d003962
Move useCustomJavaDocTags to UtSettings, make useFuzzing true
onewhl Aug 7, 2022
f8e6764
Remove unused import and fix broken tests
onewhl Aug 7, 2022
321bf0d
Fix broken tests
onewhl Aug 8, 2022
a52fb20
Add comments, remove unused method
onewhl Aug 8, 2022
83f4e71
Review fixes: fixed formatting, removed redundant types
onewhl Aug 9, 2022
abe7ca6
Review fixes: fixed formatting, removed useless overriding methods
onewhl Aug 15, 2022
475cae5
Review fixes: extracted method, polished code
onewhl Aug 15, 2022
99b06ad
fix after rebasing
onewhl Aug 17, 2022
21a7035
fix after rebasing
onewhl Aug 23, 2022
4951b6f
review fixes
onewhl Aug 23, 2022
bd616a9
fix rendering after updating to idea 2022.1. now we don't need to gen…
onewhl Aug 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix rendering after updating to idea 2022.1. now we don't need to gen…
…erate comment content with HTML tags, we need only replace custom tags' names with their messages to make it look nice
  • Loading branch information
onewhl committed Aug 24, 2022
commit bd616a98e25e945a922f0b1482f62bb1d6d8cf60
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package org.utbot.intellij.plugin.javadoc

import com.intellij.codeInsight.javadoc.JavaDocExternalFilter
import com.intellij.codeInsight.javadoc.JavaDocInfoGenerator
import com.intellij.codeInsight.javadoc.JavaDocInfoGeneratorFactory
import com.intellij.lang.java.JavaDocumentationProvider
import com.intellij.psi.PsiDocCommentBase
import com.intellij.psi.PsiJavaDocumentedElement

/**
* To render UtBot custom JavaDoc tags correctly, we need to override the way it generates HTML tags for comments.
* We get JavaDoc info generated by IJ platform and include sections related to UTBot,
* each section relates to the specific JavaDoc tag.
* It renders text, code, and links.
* To render UtBot custom JavaDoc tags messages, we need to override basic behaviour of [JavaDocumentationProvider].
* The IJ platform knows only custom tag names, so we need to add their messages in rendered comments to make it look nice.
*/
class UtDocumentationProvider : JavaDocumentationProvider() {
override fun generateRenderedDoc(comment: PsiDocCommentBase): String? {
Expand All @@ -20,16 +18,29 @@ class UtDocumentationProvider : JavaDocumentationProvider() {
return ""
}

val docComment = target.docComment ?: return ""
val baseJavaDocInfoGenerator = JavaDocInfoGeneratorFactory.getBuilder(target.getProject())
.setPsiElement(target)
.setIsGenerationForRenderedDoc(true)
.create()

val baseJavaDocInfoGenerator = JavaDocInfoGenerator(target.project, target)
// get JavaDoc comment rendered by the platform.
val baseJavaDocInfo = baseJavaDocInfoGenerator.generateRenderedDocInfo()
val utJavaDocInfoGenerator = UtJavaDocInfoGenerator()
// add UTBot sections with custom tags.
val javaDocInfoWithUtSections =
utJavaDocInfoGenerator.addUtBotSpecificSectionsToJavaDoc(baseJavaDocInfo, docComment)
val finalDocContent = replaceTagNamesWithMessages(baseJavaDocInfoGenerator.generateRenderedDocInfo())

return JavaDocExternalFilter.filterInternalDocInfo(javaDocInfoWithUtSections)
return JavaDocExternalFilter.filterInternalDocInfo(finalDocContent)
}

/**
* Replaces names of plugin's custom JavaDoc tags with their messages in the comment generated by the IJ platform.
* Example: utbot.MethodUnderTest -> Method under test.
*/
private fun replaceTagNamesWithMessages(comment: String?) =
comment?.let {
val docTagProvider = UtCustomJavaDocTagProvider()
docTagProvider.supportedTags.fold(it) { result, tag ->
if (result.contains(tag.name)) {
result.replace(tag.name, "${tag.getMessage()}:")
} else {
result
}
}
} ?: ""
}

This file was deleted.