From 649504b424bf2e9180c7a7d9b8719e43edb867c2 Mon Sep 17 00:00:00 2001 From: Bogdan Gheorghe Date: Fri, 14 May 2004 23:27:47 +0000 Subject: [PATCH] Fix for bug 60491 Added working copy filtering to search engine From now on only relevent working copies are considered for search If no index paths are found then search will return no results regardless of any working copies passed in --- core/org.eclipse.cdt.core/search/ChangeLog | 6 ++++ .../eclipse/cdt/core/search/SearchEngine.java | 33 +++++++++++++++++-- .../core/search/matching/MatchLocator.java | 4 +++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core/search/ChangeLog b/core/org.eclipse.cdt.core/search/ChangeLog index 0381f36a5c0..ec3f121e06e 100644 --- a/core/org.eclipse.cdt.core/search/ChangeLog +++ b/core/org.eclipse.cdt.core/search/ChangeLog @@ -1,3 +1,9 @@ +2004-05-14 Bogdan Gheorghe + bug 60491 + Added working copy filtering to search engine + From now on only relevent working copies are considered for search + If no index paths are found then search will return no results regardless of any working copies passed in + 2004-05-14 Andrew Niefer bug 56411 - Added IndexingJob show that indexing shows up in the process view - this allows for the index job to be cancelled, which pauses indexing until someone requests something diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/SearchEngine.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/SearchEngine.java index 202898be132..eac01f7d00f 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/SearchEngine.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/SearchEngine.java @@ -210,8 +210,10 @@ public class SearchEngine implements ICSearchConstants{ if( progressMonitor != null ) progressMonitor.subTask( Util.bind( "engine.searching" ) ); - //TODO: BOG Filter Working Copies... - matchLocator.locateMatches( pathCollector.getPaths(), workspace, this.workingCopies, matches); + String[] indexerPaths = pathCollector.getPaths(); + pathCollector = null; // release + + matchLocator.locateMatches( indexerPaths, workspace, filterWorkingCopies(this.workingCopies, scope), matches); } finally { AcceptMatchOperation acceptMatchOp = new AcceptMatchOperation(collector, matches); try { @@ -219,4 +221,31 @@ public class SearchEngine implements ICSearchConstants{ } catch (CoreException e) {} } } + + /** + * @param copies + * @param scope + * @return + */ + private IWorkingCopy[] filterWorkingCopies(IWorkingCopy[] copies, ICSearchScope scope) { + + if (copies == null || + copies.length == 0) + return copies; + + int length = copies.length; + IWorkingCopy[] results= new IWorkingCopy[length]; + int index=0; + + for (int i=0;i 0)) + return; + matchStorage = matches; workspaceRoot = (workspace != null) ? workspace.getRoot() : null;