How can i add custom expression functions for Live templates in Intellij

删除回忆录丶 提交于 2019-12-03 03:54:50

问题


How can add new custom functions for Live Templates in Idea Intellij.

For example i need a custom function which can convert a live template variable from Camel Case to Spaced. i.e in Live Template on variable has to be inserted at multiple places with & without space.

Eg. "MyVar" and "My Var". So i want to insert an expression to convert 'MyVar' to 'My Var'.

No expression available by default can be used for this.

Thanks.


回答1:


There is OpenAPI for providing Live Template functions. One can create IntelliJ IDEA plug-in that will add more functions.

See the Macro abstract class. Plug-in should define extension point, like this one:

<liveTemplateMacro implementation="com.intellij.codeInsight.template.macro.CapitalizeMacro"/>

Search IntelliJ IDEA Community code base for sample implementations.



来源:https://stackoverflow.com/questions/12156205/how-can-i-add-custom-expression-functions-for-live-templates-in-intellij

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!