1 11 package org.eclipse.jdt.core.search; 12 13 import org.eclipse.core.resources.IResource; 14 import org.eclipse.core.resources.IWorkspaceRoot; 15 import org.eclipse.core.resources.ResourcesPlugin; 16 import org.eclipse.core.runtime.*; 17 import org.eclipse.jdt.internal.core.JavaModel; 18 import org.eclipse.jdt.internal.core.JavaModelManager; 19 import org.eclipse.jdt.internal.core.search.indexing.IndexManager; 20 21 52 public abstract class SearchParticipant { 53 54 57 protected SearchParticipant() { 58 } 60 61 68 public void beginSearching() { 69 } 71 72 79 public void doneSearching() { 80 } 82 83 92 public String getDescription() { 93 return "Search participant"; } 95 96 108 public abstract SearchDocument getDocument(String documentPath); 109 110 132 public abstract void indexDocument(SearchDocument document, IPath indexLocation); 133 134 160 public abstract void locateMatches(SearchDocument[] documents, SearchPattern pattern, IJavaSearchScope scope, SearchRequestor requestor, IProgressMonitor monitor) throws CoreException; 161 162 175 public void removeIndex(IPath indexLocation){ 176 IndexManager manager = JavaModelManager.getJavaModelManager().getIndexManager(); 177 manager.removeIndexPath(indexLocation); 178 } 179 180 197 public final void scheduleDocumentIndexing(SearchDocument document, IPath indexLocation) { 198 IPath documentPath = new Path(document.getPath()); 199 IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); 200 Object file = JavaModel.getTarget(root, documentPath, true); 201 IPath containerPath = documentPath; 202 if (file instanceof IResource) { 203 containerPath = ((IResource)file).getProject().getFullPath(); 204 } else if (file == null) { 205 containerPath = documentPath.removeLastSegments(documentPath.segmentCount()-1); 206 } 207 IndexManager manager = JavaModelManager.getJavaModelManager().getIndexManager(); 208 manager.ensureIndexExists(indexLocation, containerPath); 210 manager.scheduleDocumentIndexing(document, containerPath, indexLocation, this); 211 } 212 213 227 public abstract IPath[] selectIndexes(SearchPattern query, IJavaSearchScope scope); 228 } 229 | Popular Tags |