Bug 319741 - Preferences->Java Compiler-> Errors/Warnings -> Unqualified access to instance field: Not for inner classes
Summary: Preferences->Java Compiler-> Errors/Warnings -> Unqualified access to instanc...
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5.2   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.7 M1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-13 11:33 EDT by Daniel Holmes CLA
Modified: 2010-07-19 14:21 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Holmes CLA 2010-07-13 11:33:47 EDT
Build Identifier: 20100218-1602

My team would like to use this rule, but to exclude references to outer class fields from inner classes.  The feeling is that in general they like the this. usage, but in the inner class case having to do NameOfOuterEnclosingClass.this. just feels too long.  Maybe it goes against the spirit of the rule, but an option to exclude this case would be nice.

Reproducible: Always
Comment 1 Olivier Thomann CLA 2010-07-15 11:15:21 EDT
Markus, would you support this in the UI if done ?
Comment 2 Markus Keller CLA 2010-07-19 12:49:37 EDT
I wouldn't do that. We already have too many preferences, and it's hard to justify that having "this." everywhere is acceptable but "OuterType.this" is too long. If you need the qualifier to make sure that you don't confuse fields with local variables, then this is even more important in inner types (where the fields and variables can even come from multiple enclosing methods & types).

If you're compiling against 1.5 or higher, you can use the quick fix to add @SuppressWarnings("unqualified-field-access") to inner types. And I'm sure you know about the "Java > Editor > Syntax Coloring" and "Java > Code Style" preferences (e.g. an "f" prefix for fields saves a lot of characters).
Comment 3 Daniel Holmes CLA 2010-07-19 13:35:54 EDT
That's fair.  I wanted to submit my team's feedback to my suggesting that we enable this check and see what you guys thought.
Comment 4 Olivier Thomann CLA 2010-07-19 14:21:12 EDT
Then closing as WONTFIX.
Core won't provide an option if it doesn't show up in the UI.