Bug 27448 - using SearchEngine the constructors, inner classes or packages are not found
Summary: using SearchEngine the constructors, inner classes or packages are not found
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 blocker (vote)
Target Milestone: 2.1 M4   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-11-30 03:59 EST by Adriana Nitescu CLA
Modified: 2002-12-03 08:27 EST (History)
0 users

See Also:


Attachments
HI java project (1.98 KB, application/x-zip-compressed)
2002-11-30 07:37 EST, Adriana Nitescu CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Adriana Nitescu CLA 2002-11-30 03:59:25 EST
SearchEngine doesn't work all the times.
 For example the constructors, inner classes or packages are not found.

 //-- my code calling SearchEngine
 public static void findElementDecl(String fullQName, int kind,
 IJavaSearchScope scope)

  SearchEngine searchEngine = new
  SearchEngine(JavaUI.getSharedWorkingCopies());
  searchEngine.search( ResourcesPlugin.getWorkspace()
                              , createElemDeclPattern(fullQName, kind)
                              , createWorkspaceSearchScope()
                              , collector
                              );
 }

 private static ISearchPattern createElemDeclPattern(String name, int kind)
{
  return SearchEngine.createSearchPattern(name, kind,
 IJavaSearchConstants.DECLARATIONS, IJavaSearchConstants.CASE_SENSITIVE);
 }

 public static IJavaSearchScope createWorkspaceSearchScope() {
  return SearchEngine.createWorkspaceScope();
 }

 //-- code sample
 package p;

 public class C {

     public C() {
         super();
     }

     public void method() {
     }

     class D {
     }
 }

findElementDecl("p.C", TYPE, createWorkspaceSearchScope() ); OK
findElementDecl("p.C", CLASS, createWorkspaceSearchScope() ); not found
findElementDecl("p", PACKAGE, createWorkspaceSearchScope() ); not found
findElementDecl("p.C.C()", CONSTRUCTOR, createWorkspaceSearchScope() ); not 
found
findElementDecl("p.C.method()", METHOD, createWorkspaceSearchScope() ); OK
findElementDecl("p.C.D", TYPE, createWorkspaceSearchScope() ); not found
Comment 1 Jerome Lanneluc CLA 2002-11-30 05:10:11 EST
Can you describe the workspace you're searching in? What's the project's 
classpath? Basically, I need steps to reconstruct this workspace.

Also do you have any editor open? Does it fail if all editors are closed?
Comment 2 Adriana Nitescu CLA 2002-11-30 07:37:23 EST
Created attachment 2597 [details]
HI java project 

The workspace has only one java project (in attachment).
SearchEngine has the same behavior if editors are opened or closed. 

Adriana
Comment 3 Jerome Lanneluc CLA 2002-12-01 06:40:47 EST
Except for findElementDecl("p.C", CLASS, createWorkspaceSearchScope() ); which 
is not supported (see bug 3336 and yourself to the CC list to stay informed of 
its progress), I get results for all cases. 

Note that I changed 
findElementDecl("p.C.C()", CONSTRUCTOR, createWorkspaceSearchScope() ); to
findElementDecl("p.C()", CONSTRUCTOR, createWorkspaceSearchScope() );
to get the result.
Comment 4 Adriana Nitescu CLA 2002-12-02 05:04:44 EST

For

findElementDecl("p", PACKAGE, createWorkspaceSearchScope() );
findElementDecl("p.C.D", TYPE, createWorkspaceSearchScope() );

I still don't have any results. I will look may be it is something I do wrong


-----------------------------------------------------------


There is another problem with the search engine.

I have two projects first and second having both in the classpath the default 
JRE_LIB (..\eclipse\jre\lib\rt.jar). 
The projects are not dependent on each other.
The first project is closed. 

When I search in the scope of the project "second" for the class 
"java.lang.Object" the search engine returns the java element contained in the 
archive of the project "first". 
Is this a normal behavior ? 

I expect the result to be the element contained in the archive of the 
project "second" (when I search in "second" project's scope) and both elements 
when I search in workspace scope. 

Regards
Adriana




 
Comment 5 Jerome Lanneluc CLA 2002-12-02 05:48:38 EST
Please enter a separate bug for the second problem.

For the original problem, to help you what's going one, you can run Eclipse 
with the -debug option and put a .options file in your Eclipse install 
directory with the following content:

# Turn on debug tracing for org.eclipse.jdt.core plugin
org.eclipse.jdt.core/debug=true
# Reports java search activity
org.eclipse.jdt.core/debug/search=true

You should get a trace of the search engine activity.
Comment 6 Adriana Nitescu CLA 2002-12-03 04:10:28 EST
As I supposed it was my fault (for the search of packages and inner classes). 
With the qualified name that you indicate for the constructors it works very 
well.

Adriana
Comment 7 Jerome Lanneluc CLA 2002-12-03 08:27:54 EST
Closing