Bug 215196 - problems with hierarchy search scope's encloses(IJavaElement)
Summary: problems with hierarchy search scope's encloses(IJavaElement)
Status: VERIFIED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M3   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 61185
  Show dependency tree
 
Reported: 2008-01-14 06:38 EST by Markus Keller CLA
Modified: 2009-10-29 10:53 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2008-01-14 06:38:57 EST
HEAD

The work on bug 61185 revealed some flaws with SearchEngine.createHierarchyScope(IType) and its encloses(IJavaElement) method. 

a.) When we use SearchEngine.searchAllTypeNames(..) (e.g. in FilteredTypesSelectionDialog.fillContentProvider(AbstractContentProvider, ItemsFilter, IProgressMonitor)), we also get types that are not in the chosen hierarchy, but are nested or enclosing types of the given type's hierarchy.
=> members of the type can be expected (see Javadoc of createHierarchyScope), but enclosing types are unexpected

b.) When we test types against the scope using encloses(IJavaElement) (e.g. in TypeInfoFilter.matchesScope(TypeNameMatch)), neither enclosing nor nested types are found.
=> the encloses(..) method should return true if and only if searchAllTypeNames(..) finds the type


Steps:
- install patch from bug 61185 comment 14
- in runtime workbench, create a new Plug-in project, using template "Hello, World Command"
- create
public class Bla {
	public static class InnerHandler implements IHandler {
		// use quick fix to add missing methods
	}
}
- create "public class Inner {}" as inner class of SampleHandler
- open plugin.xml > Extensions > o.e.ui.handlers > (handler)
- click "Browse..." next to the 'class:' attribute

=> Depending on whether the type selection dialog uses the search engine or its cache (calling IJavaSearchScope.encloses(IJavaElement)), elements "Bla", "InnerHandler", and "Inner" appear in the list or not.
- to use the cache: enter first character, wait until search is done, add another character
- to use the search engine: enter pattern "z", wait until search is done, select "z" and paste prefix of what you want to to find
Comment 1 Markus Keller CLA 2008-01-14 07:00:02 EST
I guess bug 61185 comment 10 mentions the same problem and Stephan proposed attachment 86635 [details] in bug 61185 comment 13 as a fix.
Comment 2 Stephan Herrmann CLA 2009-08-27 14:23:07 EDT
For cross reference: bug 215139 comment 35 ff. might decide to leave the
inconsistency in the core and leave it to clients to supply a requestor
that filters unwanted menbers/enclosings using the same hierarchy scope.
Comment 3 Stephan Herrmann CLA 2009-10-29 10:31:55 EDT
Since both bug 215139 and bug 61185 have been resolved for M3,
I gave it a try using I20091020-0931.

No matter what I tried, 
  I ALWAYS got InnerHandler and SampleHandler
  I NEVER got Bla nor Inner

Looks good, so I suggest to close this issue.
Comment 4 Frederic Fusier CLA 2009-10-29 10:42:00 EDT
Thanks Stephan for the feedback => close as WORKSFORME
Comment 5 Frederic Fusier CLA 2009-10-29 10:53:33 EDT
Verified for 3.6M3 using build  I20091028-0100.