Code format rule for adding the 'this' reference to instance field access

Does IntelliJ IDEA 10.5 Ultimate support this feature? That is to say, does it have a code formatting / clean up routine which qualifies access to instance fields with the this reference?

Example:

private String instanceField;
...
String getInstanceField()
{
    return instanceField;
}

ctrl + alt + l

private String instanceField;
...
String getInstanceField()
{
    return this.instanceField;
}

Thanks!

3 comments
Comment actions Permalink

Hello Matthew,

Code formatting in IntelliJ IDEA generally does not modify anything other
than whitespaces. What you need is the inspection 'Instance field access
not qualified with "this"'. You can enable it in Settings | Inspections and
run it on your project to see all places where "this" should be added.

Does IntelliJ IDEA 10.5 Ultimate support this feature? That is to say,
does it have a code formatting / clean up routine which qualifies
access to instance fields with the this reference?

Example:

private String instanceField;
..
String getInstanceField()
{
return instanceField;
}
ctrl + alt + l

private String instanceField;
..
String getInstanceField()
{
return this.instanceField;
}


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Hi Matthew,

No, it's not possible to add 'this.' clarification during formatting.

Denis

0
Comment actions Permalink

Thanks Dmitry, your solution was more than sufficient to meet my needs; Cheers!

0

Please sign in to leave a comment.