Bug 195489 - [search] References not found while using SearchEngine.searchDeclarationsOfReferencedTypes
Summary: [search] References not found while using SearchEngine.searchDeclarationsOfRe...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M1   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-05 04:23 EDT by Frederic Fusier CLA
Modified: 2007-08-03 09:57 EDT (History)
0 users

See Also:


Attachments
Patch with tests on JavaSearchBugTests (3.65 KB, patch)
2007-07-05 04:34 EDT, Frederic Fusier CLA
no flags Details | Diff
Proposed patch (16.12 KB, patch)
2007-07-06 08:24 EDT, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Fusier CLA 2007-07-05 04:23:28 EDT
While looking at bug 108053, I did some tests with following example:
Ref.java:
  package pack;
  public class Ref {}

Test.java:
  package pack;
  /**
   * @see Ref
   */
  public class Test {}

I discovered that SearchEngine.searchDeclarationsOfReferencedTypes method does not return any match when the given element is the Test.java ICompilationUnit although I would expect the TypeDeclaration of Ref.java as a valid match...

I'll attach a test case which will highlight this problem...
Comment 1 Frederic Fusier CLA 2007-07-05 04:34:07 EDT
Created attachment 73088 [details]
Patch with tests on JavaSearchBugTests
Comment 2 Frederic Fusier CLA 2007-07-05 04:38:40 EDT
Problem comes from the MatchLocator while locating matches on possibles matches in method locateMatches(JavaProject, PossibleMatch[], int, int).

At the end of the method each possible matches stored in 'matchesToProcess' field is processed and cleaned at the end of the loop. Doing this, type bindings scope are set to null but the scope is still necessary while reporting type declaration matches in TypeReferenceLocator.reportDeclaration(ReferenceBinding, int, MatchLocator, SimpleSet) method...
Comment 3 Frederic Fusier CLA 2007-07-06 08:20:16 EDT
This was not specific to references in javadoc comments => update summary.
Comment 4 Frederic Fusier CLA 2007-07-06 08:24:10 EDT
Created attachment 73191 [details]
Proposed patch

Finally the fix does not change anything to the cleanup as it may have performance impact. Instead, it does not add all the SearchEngine compilation units to the found SearchDocument but uses only the given java element parameter of the method searchDeclarationsOfReferencedTypes.

Then, there's only one search document which avoid to get problem with clean-up during the loop.

All JDT/Core and JDT/UI pass with this fix.
Comment 5 Frederic Fusier CLA 2007-07-06 08:24:47 EDT
Released for 3.4M1 in HEAD stream.
Comment 6 Frederic Fusier CLA 2007-08-03 09:57:14 EDT
Verified (with code of added tests) for 3.4M1 using build I20070802-0800.