Summary: | [content assist] Problem with code completion and nested classes | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Mauro Molinari <mauromol> |
Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
Status: | NEW --- | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | andy.m.sheldon, julian.honnen |
Version: | 3.3 | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows 2000 | ||
Whiteboard: | stalebug |
Description
Mauro Molinari
2007-07-27 06:04:39 EDT
The problem is quite annoying when you want to create an anonymous class using a nested interface, without declaring a variable of that type. Example: package a; public class A { public static interface I { void i(); } } package c; import a.A.I; public class C { void add(I item) { } } package b; import c.C; public class B { public B() { new C().add(new I<= invoke code completion here } } When you try to create an anonymous class that implements interface I to call C.add(I), you don't get any result, so: - no suggestion for I's name - no suggested template to create the anonymous class - no way to automatically import I, even if you type I's name manually and try Organize Imports You are forced to declare a variable of type I to enable code completion for I, otherwise you have to write A.I when typing the argument to pass to C.add(I). This example is quite trivial and dumb, but real cases are much more annoying. Mauro. In both examples provided, completion now appears to work correctly in 4.2. Did not test yet in 3.8. 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. (In reply to Andy Sheldon from comment #2) > In both examples provided, completion now appears to work correctly in 4.2. > Did not test yet in 3.8. I just tried with Eclipse 2019-12 and neither of the provided examples work as expected. The nested class/interface is not proposed when invoking code assist at the constructor call location, if it has not yet been imported. I had a cursory look at the issue and it seems like support for constructor declarations of inner types (including static classes) is missing in lots of components. At various places inner types are excluded completely (-> ExtraFlags.IsMemberType). Their index key also contains only limited information: no package name, no parameter types, no outer type, no modifiers. If the filtering of inner types is commented out, we end in CompletionEngine::acceptConstructors which tries to reconstruct a fully qualified name and checks if the type is accessible. Given the limited info from the index key, neither works correctly. Furthermore the API doesn't seem to be designed to support this usecase, as it only provides package name and simple name: char[] fullyQualifiedName = CharOperation.concat(packageName, simpleTypeName, '.'); 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. |