How can I comment a PsiElement?


I'm building a custom code inspection plugin. To this extent, I extend  AbstractBaseJavaLocalInspectionTool.

To fix the issue identified by my custom inspection, I created a quick fix class by implementing LocalQuickFix.

My requirement (i.e. fix) is to comment the code identified by my custom inspector. How do I comment the PsiElement that I obtain from descriptor.getPsiElement() within the applyFix method?

1 comment
Comment actions Permalink

This is actually not totally trivial - see com.intellij.codeInsight.generation.CommentByBlockCommentHandler as reference. Probably it could be simplified for specific Java case...


Please sign in to leave a comment.