Is there any Eclipse feature that includes "this." before any variable where this is implied?

14

Every time I see myself putting this. before variables that are class attributes in non-static methods.

Does eclipse have any option that applies this to all source files?

    
asked by anonymous 30.01.2014 / 20:22

3 answers

14

You can set this in Window-> Preferences-> Java-> Code Style-> Clean Up .

Create a new profile, or edit the current profile.

Go to the Member Accesses tab.

Check: Use 'this' qualifies for field accesses ; then just Always .

All this, just go to the Source-> Clean Up menu.

    
30.01.2014 / 20:42
1

It can also be set to automatically correct when saving the class through Save Actions ( Window-> Preferences-> Java-> Editor-> Save Actions ).

Enable the checkbox Additional actions and select Configure ... .

In the Member Accesses tab, select Use 'this' qualifier for field accesses and enable Always .

NOTE: It can also be configured for methods.

Click OK, close the preferences screen and it will already be active when saving the files.

    
31.01.2014 / 12:02
0

If you want to avoid typing this. before each variable, simply use ctrl + espaço that the variables belonging to the this. scope will appear for you to choose (autocomplete feature).

    
30.01.2014 / 20:46