在Eclipse中格式化字段声明 [英] Formatting Field Declarations in Eclipse

查看:211
本文介绍了在Eclipse中格式化字段声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候语向上,

问题(变量的名称不是它们的类型):

  public abstract class Filter {
private long id;
protected String expression;
}

如何在Eclipse中自动对齐字段,如:

  public abstract class Filter {
private long id;
protected String expression;
}

注意 long之前的空格,谢谢!



更新:我找不到一个自定义选项来调整类成员的类型(例如: long String )在Eclipse格式化程序选项下。是的,有一个可以排列类成员的名称(例如: id 表达式),而不是其类型。请看我上面的例子中的这个问题。任何解决方案?

解决方案

没有格式化选项可以做你所建议的。我有两种可能性,你们都不会非常喜欢:


  1. 在jdt.ui上增加增强请求并描述功能你要的那个。以下是bugzilla链接: https://bugs.eclipse.org/bugs/ 或者更好的为代码格式化程序提交补丁。

  2. 创建自己的Eclipse插件,为自定义操作做出这种特殊的格式化。


Greetings Overflowers,

Problem (names of variables are aligned by not their types):

public abstract class Filter {
    private long     id;
    protected String expression;
}

how can I align fields automatically in Eclipse, such in:

public abstract class Filter {
    private   long   id;
    protected String expression;
}

Note the space before long, thank you !

UPDATE: I cannot find a customization option to align types of class members (e.g.: long and String) under Eclipse formatter options. Yes, there is one to align names of class members (e.g.: id and expression) but not their types. Please, take a look at this issue in my examples above. Any solution ?

解决方案

There is no formatting option to do what you suggest. I have two possibilities, neither of which you are going to like very much:

  1. Raise an enhancement request on jdt.ui and describe the feature that you want. Here is the bugzilla link: https://bugs.eclipse.org/bugs/ Or, better yet, submit a patch for the code formatter.
  2. Create your own Eclipse plugin that contributes a custom action to do this special kind of formatting.

这篇关于在Eclipse中格式化字段声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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