TemplateContextType find context of Comment
Answered
Hi I wondered if it is possible to create a TemplateContextType so that my live tempålate only activates while in comments?
I have tried this:
public class CommentContext extends TemplateContextType {
public CommentContext() {
super("COMMENT", "Comment");
}
@Override
public boolean isInContext(@NotNull TemplateActionContext templateActionContext) {
Collection<PsiComment> comments = collectElementsOfType(templateActionContext.getFile(), PsiComment.class);
for (PsiElement comment : comments) {
return comment instanceof PsiComment;
}
return false;
}
}
But with no success. Any help would be greatly appreciated!
Please sign in to leave a comment.
See com.intellij.codeInsight.template.JavaCommentContextType as a reference implementation