`
zhaozhongwei
  • 浏览: 54560 次
  • 性别: Icon_minigender_1
  • 来自: 沈阳
社区版块
存档分类
最新评论

template

阅读更多

   <extension
         point="org.eclipse.ui.editors.templates">
      <contextType
            name="java"
            class="org.eclipse.jdt.internal.corext.template.java.JavaContextType"
            id="java">
      </contextType>

      <include
        file="templates/default-templates.xml"
        translations="$nl$/templates/default-templates.properties">
      </include>
      <include
        file="templates/default-codetemplates.xml"
        translations="$nl$/templates/default-templates.properties">
      </include>
      <include
            file="templates/default-swttemplates.xml"
            translations="$nl$/templates/default-templates.properties">
      </include>

      <resolver
            class="org.eclipse.jdt.internal.corext.template.java.ExceptionVariableNameResolver"
            contextTypeId="java"
            description="%templates.java.resolvers.ExceptionVariableName.description"
            name="%templates.java.resolvers.ExceptionVariableName.name"
            type="exception_variable_name">
      </resolver>
   </extension>

 

 

在写java代码的时候,我们写sysout然后按alt+?就会自动出现System.out.println();

 

这个功能就是通过上面的扩展点完成的,我们也可以自定义这样的功能。

 

打开模板会看到sysout对应的是System.out.println(${word_selection}${});${cursor},${}里面是变量都是通过resolver扩展点或者contextType内部的addResolver添加进来的,resolver通过contextTypeId与相应的contextType对应,在运行时把变量换成具体的值。tamplate里面定义的都被保存到include的文件里面

分享到:
评论

相关推荐

    前端插件art-template模板引擎art-template-test示例代码

    本文主要围绕`art-template`这一前端模板引擎,通过`art-template-test`示例代码来深入探讨其核心概念、使用方法以及在实际项目中的应用。 `art-template`是一个轻量级、高性能的JavaScript模板引擎,它旨在解决...

    HbaseTemplate 操作hbase

    1. **HbaseTemplate的初始化**:在使用HbaseTemplate之前,我们需要在Spring配置文件中配置HBase的相关连接信息,如Zookeeper地址、HBase表名等,并实例化HbaseTemplate。这通常通过@Autowired注解和@Configuration...

    Perl.Template.Toolkit

    Description: Among the many different approaches to "templating" with Perl--such as Embperl, Mason, HTML::Template, and hundreds of other lesser known systems--the Template Toolkit is widely ...

    c# 模板引擎TemplateEngine 源码生成

    **C# 模板引擎 TemplateEngine 源码生成** 在.NET开发环境中,C#语言以其强大而灵活的特性被广泛使用。对于许多自动化任务,如网页制作、电子邮件模板生成、XML代码生成以及源代码自动生成,开发者经常需要一种工具...

    mongoTemplate工具类Dao层方法封装.zip

    MongoTemplate是Spring Data MongoDB框架中的一个核心组件,用于在Java应用中方便地操作MongoDB数据库。这个资源包“mongoTemplate工具类Dao层方法封装.zip”显然提供了两种版本的MongoTemplate操作集合的代码示例,...

    lua-resty-template

    而lua-resty-template和大多数模板引擎是类似的,大体内容有: 模板位置:从哪里查找模板; 变量输出/转义:变量值输出; 代码片段:执行代码片段,完成如if/else、for等复杂逻辑,调用对象函数/方法; 注释:解释...

Global site tag (gtag.js) - Google Analytics