如何使用Intellij插件创建自定义实时模板 [英] How can I create custom Live Templates with an Intellij plugin
问题描述
我想创建一个可以在我的插件中使用的自定义动态模板。我知道如何使用设置对话框创建自定义动态模板,但我希望能够将动态模板作为我的插件的一部分进行分发:
I want to create a custom Live Template that will be available with my plugin. I know how to create custom Live Templates using the Settings dialog, but I want to be able to distribute the Live Template as part of my plugin:
- 如何在插件中定义实时模板?
- 在应用程序中注册它的入口点在哪里?
谢谢。
推荐答案
使用12.1.5
在查看groovy插件源后我能够完成此任务。
using 12.1.5 I was able to accomplish this after looking at the groovy plugin source.
-
继续创建您的模板使用设置对话框。它会将生成的xml文件存储在
%home%/。
下 group_name.xml
将此文件复制到 project / resources / liveTemplates
创建 DefaultLiveTemplatesProvider
的实现,并按如下方式实现:
Create an implementation of DefaultLiveTemplatesProvider
and implement as follows:
@Override
public String[] getDefaultLiveTemplateFiles()
{
return new String[] {"liveTemplates/group_name"};
}
在plugin.xml中的扩展名下添加以下内容
add the following under extensions in your plugin.xml
defaultLiveTemplatesProvider implementation="com.tridium.intellij.NiagaraTemplatesProvider"
这篇关于如何使用Intellij插件创建自定义实时模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!