Bug 25890

Summary: code assist displays static members on non-static expressions
Product: [Eclipse Project] JDT Reporter: Genady Beryozkin <eclipse>
Component: CoreAssignee: David Audel <david_audel>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.1   
Target Milestone: 2.1 M4   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Genady Beryozkin CLA 2002-11-08 09:43:33 EST
I think the javac compiler complains when I try to access static fields of a 
class using a concrete object. However, eclipse proposes static fields as 
suggestions in code assist. This is very annoying. 
For example, take the org.eclipse.jdt.internal.compiler.ast.Expression class.
It inherits many static fields. But when I have

Expression exp = ....
exp.<CTRL+SPACE> 

I don't want to see them all.
Comment 1 Philipe Mulet CLA 2002-11-08 12:39:32 EST
The compiler optionally warns you that this is a bad idea. However, it is still 
legal in Java.

Such completions should though always be less relevant than the non-static ones.

David - please consider this relevance improvement (and possibly an option to 
prevent them completely too).
Comment 2 David Audel CLA 2002-11-19 09:49:01 EST
relevance improvement:
when member is non-static then relevance is higher.

In the following example 'var2' is more relevant than 'var1' ('var2' is the 
first proposal).
public class X {
   static int var1;
   int var2;
   void foo() {
      this.var<cursor>
   }
}

Fixed.
Comment 3 David Audel CLA 2002-12-17 10:07:35 EST
Verified.
Comment 4 Genady Beryozkin CLA 2002-12-17 15:01:18 EST
Great! I will check it.