Community
Participate
Working Groups
with the fix in for bug 163984, we have the main method search for launching showing type from our context in the type dialog, but now we see types that do not contain main methods as well. use the Run As... menu item on the following code and you will see all of the types from below available in the type dialog, where we should only see Test Inner and Inner3. will attach screen shot. package a; /** */ public class Test { static class Inner extends Object { /** * @param args */ public static void main (String[] args) {} } static class Inner3 extends Inner {} /** */ static class Inner2 extends Object {} /** * @param args */ public static void main(String[] args) {} }
Created attachment 55491 [details] screen shot shows the code snippet above and the resulting type dialog - notice Inner2 is there and the default selected, but it is the only type without a main method in it...
It seems that our MainMethodSearch engine returns the correct ITypes, in this case Test, Inner, and Inner3, but when passed in as a search scope to JavaUI.createTypeDialog(...) all of the child types of Test are shown as well. There should be some way to specify whether or not to show all child types of a specified type passed in to the dialog. sending to JDT Core for comment
This is not a SearchEngine issue, neither while search main method declarations nor while searching for all types. Problem seems to come from MainMethodeSearchEngine in org.eclipse.jdt.internal.debug.ui.launcher. Method searchMainMethods(IProgressMonitor, IJavaSearchScope, boolean), there's a call to addSubTypes(List, IProgressMonitor, IJavaSearchScope) method if includesSubtypes flag is ON. This method add all types sub-types as soon as the given scope encloses them without testing if sub-types have a main method! This explain why all sub-types are added in the given test case => move (back) to JDT/Debug to fix this issue...
(In reply to comment #2) > It seems that our MainMethodSearch engine returns the correct ITypes, in this > case Test, Inner, and Inner3, but when passed in as a search scope to > JavaUI.createTypeDialog(...) all of the child types of Test are shown as well. > > There should be some way to specify whether or not to show all child types of a > specified type passed in to the dialog. > > sending to JDT Core for comment > Sorry, Michael, I missed this comment due to wrong notification order from Bugzilla :-( In fact you're right, your MainMethodSearchEngine found the correct types.... The problem here is that your use an OpenType dialog after with a scope which includes top level type 'Test' => this scope will enclose _all_ its sub-types without any possible restriction! So, the question is why do you use this kind of dialog instead of a specific one? IMO, the best solution would be to write a specific dialog MainMethodSelectionDialog inheriting from ElementListSelectionDialog with elements initialized using MainMethodSearchEngine...
Frederic, instead of us making our own dialog, could you guys add in some API that would allow users of the OpenType dialog to specify whether to include all subtypes of a type passed to the dialog? Something as simple as new flag perhaps indicating whether to include all subtypes? It seems that we would have to copy a pile of code to mimic the OpenType but with one minor change....
(In reply to comment #5) > Frederic, instead of us making our own dialog, could you guys add in some API > that would allow users of the OpenType dialog to specify whether to include all > subtypes of a type passed to the dialog? Something as simple as new flag > perhaps indicating whether to include all subtypes? > This would really not be so simple... Modify IJavaSearchScope API is not possible as this is an implementable interface => clients would be broken! > It seems that we would have to copy a pile of code to mimic the OpenType but > with one minor change.... > I really do not understand why you want to mimic OpenType dialog, it does stuff you really do not need. The main functionality of this dialog is to search type from a given pattern (using searchAllTypeNames). But in your case you already have the types before opening the dialog. What you just need is to select one of them... With a specific dialog, I guess you should not have too much code... I would say something similar than org.eclipse.jdt.internal.junit.ui.TestMethodSelectionDialog
Created attachment 55619 [details] dialog here is an implemetation of a MainMethodSelectionDialog, with label provider MainMethodLabelProvider, and changes to JavaMainTab and JavaLaunchShortcut
The open type dialog is designed to perform searching on a scope. Suggestion is to investigate the use of a FilteredItemsSelectionDialog that is similar to the open type dialog, since our search is already complete.
fixed in HEAD see MainMethodSelectionDialog
please verify Darin W
Verified.