如何配置Eclipse Formatter来添加它。在班级成员面前

时间:2023-01-14 16:01:03

How can I configure the Eclipse Formatter to add this. in front of every class member use? I can't find this in the Formatter configuration and Google does not give me reasonable answer.

如何配置Eclipse Formatter来添加它。在每个班级成员面前使用?我在Formatter配置中找不到这个,谷歌没有给我合理的答案。

I need this:

我需要这个:

public class Foo {
    private int bar;

    public void methodUsingBar(){
        bar = 1;
    }
}

To be formatted to this:

要格式化为:

public class Foo {
    private int bar;

    public void methodUsingBar(){
        this.bar = 1;
    }
}

1 个解决方案

#1


In the Eclipse Preferences go to Java -> Code Style -> Clean Up. Create or edit an (active) profile. In the Profile Edit dialog go to the Member Accesses. Configure the settings in the Non static accesses-group as wished. In your case enable Use 'this' qualifier for field accesses and check Always.

在Eclipse Preferences中转到Java - > Code Style - > Clean Up。创建或编辑(活动)配置文件。在“配置文件编辑”对话框中,转到“成员访问”。根据需要配置非静态访问组中的设置。在您的情况下,启用使用“this”限定符进行字段访问并选中“始终”。

#1


In the Eclipse Preferences go to Java -> Code Style -> Clean Up. Create or edit an (active) profile. In the Profile Edit dialog go to the Member Accesses. Configure the settings in the Non static accesses-group as wished. In your case enable Use 'this' qualifier for field accesses and check Always.

在Eclipse Preferences中转到Java - > Code Style - > Clean Up。创建或编辑(活动)配置文件。在“配置文件编辑”对话框中,转到“成员访问”。根据需要配置非静态访问组中的设置。在您的情况下,启用使用“this”限定符进行字段访问并选中“始终”。