是否有简短版本的封闭类型名称的Eclipse模板变量 [英] Is there a Eclipse template variable for short version of enclosing type name

查看:173
本文介绍了是否有简短版本的封闭类型名称的Eclipse模板变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Eclipse中为Java类创建一个构造函数模板。我有一个适用于大多数课程的版本。虽然它不适用于嵌套在其他类中的类。 (见课程 Inner 以下)如何获取类名的简短版本?



不工作的模板



  public $ {newType:surrounding_type}(){
$ {cursor}
}



示例失败类



  public class Outer {
public class Inner {
//当前模板扩展到以下
public Outer.Inner(){
}
}
}


解决方案

我检查了靛蓝。你不行据我所知,你唯一的选择是在模板列表中引入一个新的变量,以获得没有外部类名的内部类名。



如果您接受编写一些代码(阅读插件)以达到目标的努力,您可以从以下开始:





或者如果你像我一样懒惰,你可以开始下载这个项目: https://github.com/aabeling/template-variables ,并根据您的需要进行自定义。


I would like to create a constructor template in Eclipse for Java classes. I've got a version that works for most classes. Although it doesn't work for classes nested in other classes. (see class Inner below) How do I get the short version of the class name?

Not working template

public ${newType:enclosing_type}() {
    ${cursor}
}

Example failing class

public class Outer {
    public class Inner {
        // Current template expands to the following
        public Outer.Inner() {
        }
    }
}

解决方案

I checked on Indigo. You can't. Your only option, as far as i know, is to introduce a new variable in template list in order to get inner class name without the outer class(es) name(s).

If you accept the effort of writing a bit of code (read plugin) to get your goal, you can start from:

or if you are lazy like me, you can start downloading this project: https://github.com/aabeling/template-variables and customizing it as your needs.

这篇关于是否有简短版本的封闭类型名称的Eclipse模板变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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