@@ -28,27 +28,42 @@ class OverwriteAuthorInspection : OverwriteInspection() {
2828 override fun visitOverwrite (holder : ProblemsHolder , method : PsiMethod , overwrite : PsiAnnotation ) {
2929 val javadoc = method.docComment
3030 if (javadoc == null ) {
31- registerMissingTag (holder, method)
31+ registerMissingTags (holder, method)
3232 return
3333 }
3434
35- val tag = javadoc.findTagByName(" author" )
36- if (tag == null ) {
37- registerMissingTag(holder, javadoc)
35+ val authorTag = javadoc.findTagByName(" author" )
36+ if (authorTag == null ) {
37+ registerMissingTag(holder, javadoc, " author " )
3838 }
39+
40+ val reasonTag = javadoc.findTagByName(" reason" )
41+ if (reasonTag == null ) {
42+ registerMissingTag(holder, javadoc, " reason" )
43+ }
44+ }
45+
46+ private fun registerMissingTag (holder : ProblemsHolder , element : PsiElement , tag : String ) {
47+ holder.registerProblem(
48+ element,
49+ " @Overwrite methods must have an associated JavaDoc with a filled in @$tag tag" ,
50+ QuickFix (tag)
51+ )
3952 }
4053
41- private fun registerMissingTag (holder : ProblemsHolder , element : PsiElement ) {
54+ private fun registerMissingTags (holder : ProblemsHolder , element : PsiElement ) {
4255 holder.registerProblem(
4356 element,
44- " @Overwrite methods must have an associated JavaDoc with a filled in @author tag " ,
45- QuickFix
57+ " @Overwrite methods must have an associated JavaDoc with filled in @author and @reason tags " ,
58+ QuickFix ()
4659 )
4760 }
4861
49- private object QuickFix : LocalQuickFix {
62+ private class QuickFix (val tag : String? = null ) : LocalQuickFix {
63+
64+ override fun getFamilyName () = " Add missing Javadoc tag"
5065
51- override fun getFamilyName () = " Add @author Javadoc tag"
66+ override fun getName (): String = if (tag == null ) " Add all missing Javadoc tags " else " Add @ $tag Javadoc tag"
5267
5368 override fun applyFix (project : Project , descriptor : ProblemDescriptor ) {
5469 val element = descriptor.psiElement
@@ -58,14 +73,15 @@ class OverwriteAuthorInspection : OverwriteInspection() {
5873 if (javadoc == null ) {
5974 // Create new Javadoc comment
6075 method.addBefore(
61- JavaPsiFacade .getElementFactory(project).createDocCommentFromText(" /**\n * @author \n */" ),
76+ JavaPsiFacade .getElementFactory(project)
77+ .createDocCommentFromText(" /**\n * @author \n * @reason \n */" ),
6278 method.modifierList
6379 )
6480 return
6581 }
6682
6783 // Create new Javadoc tag
68- val tag = JavaPsiFacade .getElementFactory(project).createDocTagFromText(" @author " )
84+ val tag = JavaPsiFacade .getElementFactory(project).createDocTagFromText(" @$tag " )
6985 javadoc.addAfter(tag, null )
7086 }
7187 }
0 commit comments