Community
Participate
Working Groups
Build F2 Enter the following class into Eclipse: public class Foo { public void bar() { } public Object x = new Object() { public void quux() { } } } If you select 'bar' in the Java editor and search for 'Declarations'->'In Workspace' the search proceeds as expected. But if you select 'quux' instead, you get an error dialog that 'The operation is unavailable on the current element, please select a valid Java element name.' quux is a valid Java element name, and the search should work.
Oops - missing a semicolon in the example. The code should be: public class Foo { public void bar() { } public Object x = new Object() { public void quux() { } }; }
Two issues: - we are using code resolve to convert a selection into a Java element. Since there isn't a Java element for local and anonymous types code resolve doesn't return the correct Java element. - I even didn't find a way to do the search in the Search dialog. There is no way to enter a "signature" for anonymous inner types.
Moving to J Core for comment.
As Dirk said there is no IJavaElement for anonymous or local types in the Java model. When resolving maybe we could return a non-existing IJavaElement: "java.lang.Object.quux()"
What should I do with a non-existent Java Element? How would I feed it into the Search engine?
I was just thinking out loud. I was expecting that SearchEngine.search (IWorkspace, IJavaElement, int, IJavaSearchScope, IJavaSearchResultCollector) would not need to open the element. This is not currently true. Need to find another solution.
The more general issue of having IJavaElements for local and anonymous types will be investigated after 2.1.
It is now "after 2.1" as comment #7 says. Would this bug be investigated now? or later?
Having IJavaElement handles on local constructs is on the 3.0 plan (see http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/jdt-core- home/r3.0/main.html#release-plan).
Closing as this is now supported.
This issue appears to be fixed in eclipse 3.1
As of now 'LATER' and 'REMIND' resolutions are no longer supported. Please reopen this bug if it is still valid for you.