Community
Participate
Working Groups
SelectionDialog dialog = JavaUI.createTypeDialog( xx.getShell(), null, SearchEngine.createHierarchyScope(throwable), // scope IJavaElementSearchConstants.CONSIDER_ALL_TYPES, // style true); // multiple selection When you type the pattern "E", there is nothing in the "Matching types" list. I'm using 31RC1
JDT/UI passes the hierarchy scope 1:1 to the all type name search. Moving to JDT/Core.
I'm not sure to understand your sample. What is throwable? What matches do you expect with pattern "E"? Can you provide more details on your test case? TIA
The hierarchy scope is created on class Throwable. Since Exception is a subclass of Throwable typing in E and a pattern should list Exception
Dirk, Can you give exact values for argument that UI gives to searchAllTypeNames method (same way you did in bug 99915 comment 2)? Thx
packagePattern:= null pattern:= E* flags:= 2 (== SearchPattern.R_PATTERN_MATCH) elementKind:= 0 // meaning types scope:= SearchEngine.createHierarchyScope(Throwable) IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH
I'm not able to reproduce this problem using N20050615-0010. I've added following test case to JavaSearchBugsTests and it pass: /** * Bug 97120: [search] SearchEngine.createHierarchyScope() ... * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=97120" */ public void testBug97120() throws CoreException { IType type = getClassFile("JavaSearchBugs", getExternalJCLPathString("1.5"), "java.lang", "Throwable.class").getType(); IJavaSearchScope scope = SearchEngine.createHierarchyScope(type); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine().searchAllTypeNames( null, "E*".toCharArray(), SearchPattern.R_PATTERN_MATCH, TYPE, scope, requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null ); assertSearchResults( "Unexpected all type names", "java.lang.Error\n" + "java.lang.Exception", requestor ); }
To be perfectly exact I've done test with N20050615-0010 + JDT/Core HEAD.
Frederic, I can still reproduce this. I will attach a patch to the OpenTypeDialog that opens the dialog in this mode. All you have to have is a project XX in your workspace to access the throwable class.
Created attachment 23187 [details] Patch against open type action
Created attachment 23189 [details] Showing the parameters for the all type names search call
Dirk, I'm still not able to reproduce even with your patch. I've also made tests with yesterday's nightly build and RC2. I always get correct "Matching Types" list! For all builds, here are arguments send to searchAllTypeNames method (I've changed 'XX' project to 'b97120'): BasicSearchEngine.searchAllTypeNames(char[], char[], int, int, IJavaSearchScope, IRestrictedAccessTypeRequestor, int, IProgressMonitor) - package name: null - type name: E* - match rule: 2 - search for: 0 - scope: HierarchyScope on Throwable [in Throwable.class [in java.lang [in D:\a\JDKs\sun\1.4.2\jre\lib\rt.jar [in b97120]]]] I'll attach snapshot of resulting dialog which shows "Matching Types" list with expected "E*" types...
Created attachment 23298 [details] Open Type Dialog with correct "Matched Types" list
Still cannot reproduce using a plugin with following action: import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.core.search.SearchEngine; import org.eclipse.jdt.core.tests.utils.actions.AbstractAction; import org.eclipse.jdt.ui.IJavaElementSearchConstants; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.ui.dialogs.SelectionDialog; public class TestBug97120 extends AbstractAction { protected void run(Object obj) throws Exception { if (obj instanceof ICompilationUnit) { this.type = ((ICompilationUnit) obj).findPrimaryType(); } else if (obj instanceof IClassFile) { this.type = ((IClassFile) obj).getType(); } else if (obj instanceof IType) { this.type = (IType) obj; } else { System.err.println(obj.getClass().getName()+" is not a valid class for this action!!!"); return; } System.out.println("Open Type Dialog with using Hierarchy Scope on "+this.type.getPath()); IJavaSearchScope scope = SearchEngine.createHierarchyScope(this.type); SelectionDialog dialog = JavaUI.createTypeDialog(null, null, scope, // scope IJavaElementSearchConstants.CONSIDER_ALL_TYPES, // style true); // multiple selection dialog.open(); } } In the opened dialog, I type 'E' and get all sub-types of Throwable starting with E...
Retested it on the latest and it works now for me as well.
Thanks Dirk for the feedback => close as WORKSFORME