1 11 package org.eclipse.jdt.internal.core.search; 12 13 import org.eclipse.core.runtime.*; 14 import org.eclipse.jdt.core.search.*; 15 import org.eclipse.jdt.internal.core.search.indexing.BinaryIndexer; 16 import org.eclipse.jdt.internal.core.search.indexing.SourceIndexer; 17 import org.eclipse.jdt.internal.core.search.matching.MatchLocator; 18 19 29 public class JavaSearchParticipant extends SearchParticipant { 30 31 IndexSelector indexSelector; 32 33 36 public void beginSearching() { 37 super.beginSearching(); 38 this.indexSelector = null; 39 } 40 41 44 public void doneSearching() { 45 this.indexSelector = null; 46 super.doneSearching(); 47 } 48 49 52 public String getDescription() { 53 return "Java"; } 55 56 59 public SearchDocument getDocument(String documentPath) { 60 return new JavaSearchDocument(documentPath, this); 61 } 62 63 66 public void indexDocument(SearchDocument document, IPath indexPath) { 67 document.removeAllIndexEntries(); 70 String documentPath = document.getPath(); 71 if (org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(documentPath)) { 72 new SourceIndexer(document).indexDocument(); 73 } else if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(documentPath)) { 74 new BinaryIndexer(document).indexDocument(); 75 } 76 } 77 78 81 public void locateMatches(SearchDocument[] indexMatches, SearchPattern pattern, 82 IJavaSearchScope scope, SearchRequestor requestor, IProgressMonitor monitor) throws CoreException { 83 84 MatchLocator matchLocator = 85 new MatchLocator( 86 pattern, 87 requestor, 88 scope, 89 monitor 90 ); 91 92 93 if (monitor != null && monitor.isCanceled()) throw new OperationCanceledException(); 94 matchLocator.locateMatches(indexMatches); 95 96 97 if (monitor != null && monitor.isCanceled()) throw new OperationCanceledException(); 98 99 matchLocator.locatePackageDeclarations(this); 100 } 101 102 105 public IPath[] selectIndexes( 106 SearchPattern pattern, 107 IJavaSearchScope scope) { 108 109 if (this.indexSelector == null) { 110 this.indexSelector = new IndexSelector(scope, pattern); 111 } 112 return this.indexSelector.getIndexLocations(); 113 } 114 115 } 116 | Popular Tags |