Bug 49120 - search doesn't find references to anonymous inner methods
Summary: search doesn't find references to anonymous inner methods
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M7   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-12-18 12:29 EST by Thomas M??der CLA
Modified: 2004-02-12 09:48 EST (History)
0 users

See Also:


Attachments
Proposed patch (6.97 KB, patch)
2003-12-19 05:28 EST, Jerome Lanneluc CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas M??der CLA 2003-12-18 12:29:19 EST
I 2003-12-18-09:55

1) create a class like so:

/*
 * Created on Dec 18, 2003
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */

/**
 * @author tma
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public class Test1 {

	public static void main(String[] args) {
		Runnable r= new Runnable() {
			public void run() {
				System.out.println("bla");
			}
		};
		r.run();
	}
}

2) select the declaration of run() in the inner class
3) do a search for references in the workpaces
4) observe: you get no matches.

By accident, I had a breakpoint on NullPointerException, and I got the following
stack trace in the debugger (the exception is eaten silently):

Javadoc.resolve(MethodScope) line: 122
FieldDeclaration.resolve(MethodScope) line: 224
TypeDeclaration.resolve() line: 910
TypeDeclaration.resolve(CompilationUnitScope) line: 975
CompilationUnitDeclaration.resolve() line: 271
MatchLocator.process(PossibleMatch, boolean) line: 888
MatchLocator.locateMatches(JavaProject, PossibleMatch[], int, int) line: 621
MatchLocator.locateMatches(JavaProject, PossibleMatchSet) line: 658
MatchLocator.locateMatches(SearchDocument[]) line: 749
JavaSearchParticipant.locateMatches(SearchDocument[], SearchPattern,
IJavaSearchScope, SearchRequestor, IProgressMonitor) line: 155
MethodPattern(InternalSearchPattern).findMatches(SearchParticipant[],
IJavaSearchScope, SearchRequestor, IProgressMonitor) line: 199
SearchEngine.search(SearchPattern, SearchParticipant[], IJavaSearchScope,
SearchRequestor, IProgressMonitor) line: 729
SearchEngine.search(IWorkspace, ISearchPattern, IJavaSearchScope,
IJavaSearchResultCollector) line: 697
SearchEngine.search(IWorkspace, IJavaElement, int, IJavaSearchScope,
IJavaSearchResultCollector) line: 678
JavaSearchOperation.execute(IProgressMonitor) line: 97
WorkspaceModifyOperation$1.run(IProgressMonitor) line: 91
Workspace.run(IWorkspaceRunnable, ISchedulingRule, int, IProgressMonitor) line: 1555
JavaSearchOperation(WorkspaceModifyOperation).run(IProgressMonitor) line: 105
ModalContext$ModalContextThread.run() line: 101
Comment 1 Jerome Lanneluc CLA 2003-12-18 13:27:04 EST
Was not working in M5 either. Not critical.
Comment 2 Jerome Lanneluc CLA 2003-12-19 05:28:32 EST
Was not able to reproduce the NPE. However this is not the cause of the failure 
to find references to anonymous inner methods. Problem is in the 
SuperTypeNamesCollector that doesn't handle anonymous types correctly.
Comment 3 Jerome Lanneluc CLA 2003-12-19 05:28:58 EST
Created attachment 7250 [details]
Proposed patch
Comment 4 Jerome Lanneluc CLA 2004-01-05 12:05:26 EST
Released proposed patch+fix to ASTNodeFinder that didn't find methods with no 
args.

Added regression test JavaSearchTests.testMethodReference5()
Comment 5 David Audel CLA 2004-02-12 09:48:34 EST
Verified for 3.0M7