如何使用自定义语言 "context" 创建 Intellij 实时模板?

how to create Intellij live templates in a custom language "context"?

我正在为自定义语言构建自定义语言插件。我想为此语言添加一些实时模板,但新语言没有显示在“更改所选模板的上下文类型”菜单中的可用上下文列表中。

该插件已经有一个 plugin.xml,带有您常用的与语言相关的扩展: <annotator><fileType><lang.parserDefinition><lang.syntaxHighlighterFactory> 等。我是否缺少相关的扩展名?

簿记:这道题was already asked 4 years ago。但是给出的答案并没有解决我的问题,而且我没有足够的声誉来发表评论或要求澄清。

看起来插件需要实现 com.intellij.codeInsight.template.TemplateContextType,然后将实现注册为 <liveTemplateContext>

此文档提供了有用的详细信息:https://plugins.jetbrains.com/docs/intellij/template-support.html#implement-templatecontexttype