Bug 395609 - Inner interface not offered for code assist
Summary: Inner interface not offered for code assist
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.2.1   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2012-12-03 10:04 EST by Viliam Anirud CLA
Modified: 2022-07-28 19:27 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Viliam Anirud CLA 2012-12-03 10:04:01 EST
I have a class with inner interface in package "pkg1":

	package pkg1;

	public class ClassWithInnerInterface {

		public void method(Interface ifc) {
		}
	
		public static interface Interface {
		}
	
	}


Now, in a class in another package, I want to create an instance of that interface, as anonymous class:

public class TestClass {

	public static void main(String[] args) {
		new Interfac
	}
	
}

After typing "new Interfac", nothing is offered to completion. If the Interface interface was in a separate class, i will offer to create anonymous inner type.

An code assist is, however, offered, if you call a method with Interface parameter, such as the "method" method in the above class:

import pkg1.ClassWithInnerInterface;

public class TestClass {

	public static void main(String[] args) {
		ClassWithInnerInterface o = new ClassWithInnerInterface();
		o.method(new Inter)
	}
	
}

However, no import of "pkg1.ClassWithInnerInterface.Interface" is added and a compilation error appears.

Reproduces in 3.8.1 as well. This inner interfaces are used for widget listeners in Vaadin framework, I enter into it quite frequently.
Comment 1 Jay Arthanareeswaran CLA 2012-12-04 00:19:49 EST
Reproduced with HEAD, and all the way back to 3.6.

I am afraid we won't be able to get to this any time soon. Anyone willing to take this up and post a patch is welcome, though!
Comment 2 Arne Deutsch CLA 2015-10-15 11:19:09 EDT
I did a little bit of research about this one. Seems like the bug is inside CompletionEngine.findTypesAndPackages. This method does not find the interface inside the class.

There seem to be more related bugs to this method. Writing the name of the interface fully ("new Interface") and pressing CTRL+1 does not propose to import the missing name (the call also ends up in this method but is not able to detect the nested interface). Interestingly organize import does add the import as expected (guess there is a second implementation of this functionality used by organize imports functionality only).

Additional observation: setting local variable "proposeAllMemberTypes" to "true" in debugger leads CTRL+1 to work and return the correct import (but autocompletion is then still broken).
Comment 3 Jay Arthanareeswaran CLA 2015-11-09 02:36:24 EST
I spent some time investigating this and figured that the index is not returning the inner types when the assist request is for constructors:

org.eclipse.jdt.core.search.SearchPattern.findIndexMatches(Index, IndexQueryRequestor, SearchParticipant, IJavaSearchScope, IProgressMonitor)

Also note that when we don't have the 'new' the proposal appears. That's because the 'proposeType' is set to true and proposeConstructor set to false, which results in type being found from the name environment.

Manoj, can you please comment on this?

Note: Manoj is on vacation and could only respond after middle of Nov.
Comment 4 Manoj N Palat CLA 2016-04-20 23:41:42 EDT
missed this out - moving to 4.7
Comment 5 Manoj N Palat CLA 2018-05-16 01:30:12 EDT
Bulk move out of 4.8
Comment 6 Eclipse Genie CLA 2020-06-28 14:18:09 EDT
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.
Comment 7 Eclipse Genie CLA 2022-07-28 19:27:58 EDT
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.