Skip to content

Commit d17ea26

Browse files
committed
Introduce custom plugin's JavaDoc tags #565
1 parent 6acc38c commit d17ea26

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package org.utbot.intellij.plugin.javadoc
2+
3+
import com.intellij.psi.PsiElement
4+
import com.intellij.psi.PsiMethod
5+
import com.intellij.psi.PsiReference
6+
import com.intellij.psi.javadoc.CustomJavadocTagProvider
7+
import com.intellij.psi.javadoc.JavadocTagInfo
8+
import com.intellij.psi.javadoc.PsiDocTagValue
9+
10+
/**
11+
* Provides plugin's custom JavaDoc tags to make test summaries structured.
12+
*/
13+
class UtCustomJavaDocTagProvider : CustomJavadocTagProvider {
14+
override fun getSupportedTags(): List<JavadocTagInfo> =
15+
listOf(
16+
UtCustomTag.ClassUnderTest,
17+
UtCustomTag.MethodUnderTest,
18+
UtCustomTag.ExpectedResult,
19+
UtCustomTag.ActualResult,
20+
UtCustomTag.Executes,
21+
UtCustomTag.Invokes,
22+
UtCustomTag.ReturnsFrom,
23+
UtCustomTag.ThrowsException,
24+
)
25+
26+
sealed class UtCustomTag(private val name: String) : JavadocTagInfo {
27+
override fun getName(): String = name
28+
29+
override fun isInline() = false
30+
31+
override fun checkTagValue(value: PsiDocTagValue?): String? = null
32+
33+
override fun getReference(value: PsiDocTagValue?): PsiReference? = null
34+
35+
override fun isValidInContext(element: PsiElement?): Boolean {
36+
return element is PsiMethod
37+
}
38+
39+
object ClassUnderTest : UtCustomTag("utbot.classUnderTest")
40+
object MethodUnderTest : UtCustomTag("utbot.methodUnderTest")
41+
object ExpectedResult : UtCustomTag("utbot.expectedResult")
42+
object ActualResult : UtCustomTag("utbot.actualResult")
43+
object Executes : UtCustomTag("utbot.executes")
44+
object Invokes : UtCustomTag("utbot.invokes")
45+
object ReturnsFrom : UtCustomTag("utbot.returnsFrom")
46+
object ThrowsException : UtCustomTag("utbot.throwsException")
47+
}
48+
}

utbot-intellij/src/main/resources/META-INF/plugin.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
<registryKey defaultValue="false" description="Enable editing Kotlin test files" key="kotlin.ultra.light.classes.empty.text.range"/>
3535
<postStartupActivity implementation="org.utbot.intellij.plugin.ui.GotItTooltipActivity"/>
3636
<projectModelModifier implementation="org.utbot.intellij.plugin.util.UtProjectModelModifier"/>
37+
<!--Documentation-->
38+
<customJavadocTagProvider implementation="org.utbot.intellij.plugin.javadoc.UtCustomJavaDocTagProvider"/>
3739
</extensions>
3840

3941
<!-- Minimum and maximum build of IDE compatible with the plugin -->

0 commit comments

Comments
 (0)