Community
Participate
Working Groups
Build Identifier: 20100218-1602 I have a class which contains an enumerated type. When I extend that class, code completion does not recognize the enumerated type from the parent class. Reproducing requires the creation of 3 classes, which are below: public class Parent { public static enum Type { TYPE_1, TYPE_2, TYPE_3 } public static int i = 0; } public class Child extends Parent { } public class Test { public Test() { Child child = new Child(); child.i <------ Code completion properly recognizes int type child. <------ Code completion does not recognize enum "Type" } } Reproducible: Always Steps to Reproduce: 1. Create class Parent 2. Create a 'public static enum' attribute in Parent 3. Create class Child, which extends Parent 4. Create a class Test, in this class, create an instance of Child 5. On that instance, hit the '.' to bring up code completion. You will not find the enumerated type available there
Already writing child.i is debatable and actually triggers a warning "The static field Parent.i should be accessed in a static way" (which may or may not be enabled in your settings). "child.Type" isn't even accepted by the compiler: "child.Type cannot be resolved to a type" so it wouldn't be a good idea to propose this for completion :) The proper way for using "Type" is "Parent.Type": - don't use an instance to qualify a static member type - for static members use the actual declaring type as qualification, not a subclass
Created attachment 173485 [details] Screenshot of code completion
(In reply to comment #1) > Already writing child.i is debatable and actually triggers a warning > "The static field Parent.i should be accessed in a static way" > (which may or may not be enabled in your settings). > > "child.Type" isn't even accepted by the compiler: > "child.Type cannot be resolved to a type" > so it wouldn't be a good idea to propose this for completion :) > > The proper way for using "Type" is "Parent.Type": > - don't use an instance to qualify a static member type > - for static members use the actual declaring type as qualification, > not a subclass Yes, my apologies. I did not mean to access the static member with an instantiation. Please disregard the instantiation portion. Instead, for Test I meant to put: public class Test { public Test() { Child. } } However, it seems that other static types that are declared in the parent are recognized by code completion in the Child. I have tested the following primitive types and objects, and code completion recognizes all of them except the enum type. Please find example code below: public class Parent { public static enum Type { TYPE_1, TYPE_2, TYPE_3 } public static long l = 0; public static int i = 0; public static short sh = 0; public static double d = 0d; public static float f = 0f; public static char ch = 'a'; public static String s = ""; public static StringBuilder sb = new StringBuilder(); } public class Child extends Parent { } public class Test { public Test() { Child. <----- Code completion recognizes every static attribute except of type "enum" (does not recognize "Type") Child.Type. <------ Code completion recognizes "TYPE_1, TYPE_2, TYPE_3" } } Also, please find a screenshot attached. Thanks! Kindest Regards, Chad
Created attachment 173486 [details] Screenshot of code completion recognizing after manually type "Type"
Ayush, please investigate. Thanks.
I'll take a look
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.
Child.x access for a static member of Parent is not recommended and will trigger a warning. Hence I don't see a priority in changing completion to propose more of that kind.
Verified for 4.11 M3