Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 495560

Summary: Searching for references to method java.util.EventListenerProxy.getListener() in java.awt.event.AWTEventListenerProxy.eventDispatched(AWTEvent) returns no results
Product: [Eclipse Project] JDT Reporter: Raffi Khatchadourian <raffi.khatchadourian>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: minor    
Priority: P3 CC: raffi.khatchadourian, stephan.herrmann
Version: 3.1   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X   
Whiteboard: stalebug

Description Raffi Khatchadourian CLA 2016-06-06 15:21:44 EDT
I am using the SearchEngine API to search for references to the method java.util.EventListenerProxy.getListener() within the scope of method java.awt.event.AWTEventListenerProxy.eventDispatched(AWTEvent). This method, i.e., eventDispatched(AWTEvent) in Java 8, has a single call to getListener(), but, somehow, the match never gets accepted. I have included some debugging information below:

Pattern: MethodReferencePattern: java.util.eventlistenerproxy.getlistener() --> t, exact match, case insensitive, generic full match, fine grain: none
Scope: JavaSearchScope on [
	eventDispatched(AWTEvent) {key=Ljava/awt/event/AWTEventListenerProxy;.eventDispatched(Ljava/awt/AWTEvent;)V} [in AWTEventListenerProxy [in [Working copy] AWTEventListenerProxy.java [in java.awt.event [in src [in java8]]]]]
]

I believe that the problem is in the MatchLocator ctor. The sourceType.getOuterMostLocalContext() returns null for source type: class EventListenerProxy.

-- Configuration Details --
Product: Eclipse 4.5.2.20160218-0600 (org.eclipse.epp.package.committers.product)
Installed Features:
 org.eclipse.jdt 3.11.2.v20160212-1500
Comment 1 Raffi Khatchadourian CLA 2016-06-06 15:22:55 EDT
As a regression, when I do the search manually from the IDE (i.e., using the search dialog), I cannot set the scope to a single method (as far as I know). I set it to the enclosing project, and it seems to work.
Comment 2 Eclipse Genie CLA 2019-09-18 10:23: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.
Comment 3 Stephan Herrmann CLA 2019-09-18 16:43:56 EDT
(In reply to Raffi Khatchadourian from comment #0)
> I believe that the problem is in the MatchLocator ctor. The
> sourceType.getOuterMostLocalContext() returns null for source type: class
> EventListenerProxy.

This certainly is a read herring, see the comment:

/*
 * Returns the outermost context defining a local element. Per construction, it can only be a
 * method/field/initializarer member; thus, returns null if this member is already a top-level type or member type.
 * e.g for X.java/X/Y/foo()/Z/bar()/T, it will return X.java/X/Y/foo()
 */

EventListenerProxy is a toplevel type so it has no local context.


I can't say much about use of a method as a search scope for the search engine. Sounds a bit like abuse of the search engine, if you ask me. Rather than going the long way through index and all, why not directly use a visitor?
Comment 4 Raffi Khatchadourian CLA 2019-09-19 10:47:26 EDT
(In reply to Stephan Herrmann from comment #3)
> (In reply to Raffi Khatchadourian from comment #0)
> > I believe that the problem is in the MatchLocator ctor. The
> > sourceType.getOuterMostLocalContext() returns null for source type: class
> > EventListenerProxy.
> 
> This certainly is a read herring, see the comment:
> 
> /*
>  * Returns the outermost context defining a local element. Per construction,
> it can only be a
>  * method/field/initializarer member; thus, returns null if this member is
> already a top-level type or member type.
>  * e.g for X.java/X/Y/foo()/Z/bar()/T, it will return X.java/X/Y/foo()
>  */
> 
> EventListenerProxy is a toplevel type so it has no local context.
> 
> 
> I can't say much about use of a method as a search scope for the search
> engine. Sounds a bit like abuse of the search engine, if you ask me. Rather
> than going the long way through index and all, why not directly use a
> visitor?

I can't remember why I was doing this and not using a visitor, but perhaps it was for uniformity with some other searches I was doing. Maybe there should be an exception thrown instead of it not finding any matches?
Comment 5 Stephan Herrmann CLA 2019-09-19 11:49:29 EDT
(In reply to Raffi Khatchadourian from comment #4)
> [..] Maybe there
> should be an exception thrown instead of it not finding any matches?

Do you want to propose a patch in this direction?

I wouldn't except any one from the JDT team to work on this with priority.