Bug 101777

Summary: [search] selecting class with a main type ignores the default package
Product: [Eclipse Project] JDT Reporter: Genady Beryozkin <eclipse>
Component: CoreAssignee: Jerome Lanneluc <jerome_lanneluc>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: frederic_fusier
Version: 3.1   
Target Milestone: 3.2 M2   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Improved JavaSearchScope
none
Regression tests none

Description Genady Beryozkin CLA 2005-06-25 17:33:13 EDT
If I select the default package and do "Run As->Java application" I get the
message that "the selection does not contain a main type" even if there is a
class in the default package that has a main type.

If I select the whole project I get a list with many classes, but the class in
the default package does not appear there.

Is it a regression from earlier builds? I don't remember that it was not working
before.
Comment 1 Darin Wright CLA 2005-06-26 11:36:24 EDT
This works for me on RC4, which build are you using?
Comment 2 Darin Wright CLA 2005-06-26 11:39:14 EDT
OK, I found it does not work for a simple project layout with *no* source 
folder. If I create a project 'P' with a main type 'A' in the top level 
folder, the main type is not found. If I create a 'src' folder that contains 
the top level type 'A', then it works.
Comment 3 Darin Wright CLA 2005-06-26 11:49:01 EDT
This did work properly in M6 - not sure when it got broken.
Comment 4 Darin Wright CLA 2005-06-26 12:05:39 EDT
Moving to JCORE for comment. It appears we set up a search scope for main 
methods and perform the search in the default package, getting no results when 
the project has a simple setup (i.e. source and binaries in the root folder). 
However, the search works when there is a top level source folder, and 
separate output folder.

To step thru our code that performs the search. Place a breakpoint in 
MainMethodSearchEngine.searchMainMethods(IProgressMonitor pm, IJavaSearchScope 
scope, boolean includeSubtypes), and invoke the "Run As > Java Application" on 
a default package.
Comment 5 Genady Beryozkin CLA 2005-06-26 12:23:38 EDT
You're right, I don't have a source folder defined.
I have two questions irrelevant to this bug:
1. why by default the projects are creating without separate source folders?
2. can MainMethodSearchEngine be made an API? There are already two 
implementations of this class and I needed a similar functionality to 
implement the launcher in my RMI Plugin.

Thanks,
Genady
Comment 6 Jerome Lanneluc CLA 2005-06-29 10:11:42 EDT
Created attachment 24130 [details]
Improved JavaSearchScope
Comment 7 Jerome Lanneluc CLA 2005-06-29 10:12:01 EDT
Created attachment 24131 [details]
Regression tests
Comment 8 Frederic Fusier CLA 2005-06-29 11:12:37 EDT
*** Bug 101602 has been marked as a duplicate of this bug. ***
Comment 9 Jerome Lanneluc CLA 2005-08-17 05:21:14 EDT
Released fix from comment 6 and tests from comment 7 were improved and moved to
a new class JavaSearchScopeTests by Frederic.
Comment 10 Olivier Thomann CLA 2005-09-20 11:51:56 EDT
Verified in I20050920-0010 for 3.2M2