diff options
author | Bogdan Gheorghe | 2004-05-14 23:27:47 +0000 |
---|---|---|
committer | Bogdan Gheorghe | 2004-05-14 23:27:47 +0000 |
commit | 649504b424bf2e9180c7a7d9b8719e43edb867c2 (patch) | |
tree | 520635ceb5588adf13d8386a1f26051f06a87c09 | |
parent | 0f10e95c219e3b3e691f404a15dd940d5baca8f2 (diff) | |
download | org.eclipse.cdt-649504b424bf2e9180c7a7d9b8719e43edb867c2.tar.gz org.eclipse.cdt-649504b424bf2e9180c7a7d9b8719e43edb867c2.tar.xz org.eclipse.cdt-649504b424bf2e9180c7a7d9b8719e43edb867c2.zip |
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
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<length;i++){ + IWorkingCopy workingCopy = copies[i]; + if(scope.encloses(workingCopy.getPath().toOSString())){ + results[index++]=workingCopy; + } + } + + System.arraycopy(results,0,results= new IWorkingCopy[index],0,index); + + return results; + } } diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java index dbf7f836762..32ef17dadb1 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java @@ -344,6 +344,10 @@ public class MatchLocator implements IMatchLocator{ public void locateMatches( String [] paths, IWorkspace workspace, IWorkingCopy[] workingCopies,ArrayList matches ) throws InterruptedException{ + + if (!(paths.length > 0)) + return; + matchStorage = matches; workspaceRoot = (workspace != null) ? workspace.getRoot() : null; |