以编程方式添加代码模板? [英] Programmatically add code templates?

查看:95
本文介绍了以编程方式添加代码模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我们的项目编写一个自定义XML编辑器,并希望添加对模板的支持。当用户写入< ab:mytag 并按ctrl + space时,可以选择使用默认/虚拟参数插入一段文本。



但是这应该仅在XML编辑器中可用。我将如何解决这个问题?



澄清:我正在谈论的模板是可写的例子,如syso在你的java编辑器中,然后按ctrl + space。在首选项中,您可以添加自己的模板。
我想做的是定义我自己的模板,对于我自己的XML标签,但是我想在代码中执行此操作,只会影响我的编辑器。

解决方案

经过多次搜索,我发现这个ppt,几乎回答了我所有的问题:



http://www.eclipsecon.org/2008/sub/attachments/Extending_the_XML_and_SSE_editors_from_the_WTP_Project_.ppt



我以后的模板可以使用扩展点org.eclipse.ui.editors.templates


进行编程添加

I'm writing a custom XML editor for our project and want to add support for templates. I.e when the user writes "<ab:mytag" and presses ctrl + space they get the option of inserting a chunk of text with a default/dummy parameters.

But this should be available only in the XML editor. How would I go about this?

Clarification: The templates I'm talking about are the ones available when you write for example "syso" in your java editor and press ctrl + space. In preferences you can add your own templates. What I want to do is do define my own templates, for my own XML tags, but I want to do this in the code and have it only effect my editor

解决方案

After alot of searching I fount this ppt that answered almost all questions I had:

http://www.eclipsecon.org/2008/sub/attachments/Extending_the_XML_and_SSE_editors_from_the_WTP_Project_.ppt

The templates I was after can programatically be added with the use of the extension point org.eclipse.ui.editors.templates

这篇关于以编程方式添加代码模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆