1 11 package org.eclipse.jdt.internal.core.search.indexing; 12 13 import java.io.IOException ; 14 15 import org.eclipse.core.resources.IProject; 16 import org.eclipse.core.runtime.IPath; 17 import org.eclipse.core.runtime.IProgressMonitor; 18 import org.eclipse.core.runtime.Path; 19 import org.eclipse.jdt.internal.core.index.Index; 20 import org.eclipse.jdt.internal.core.search.processing.JobManager; 21 import org.eclipse.jdt.internal.core.util.Util; 22 23 class RemoveFolderFromIndex extends IndexRequest { 24 IPath folderPath; 25 char[][] inclusionPatterns; 26 char[][] exclusionPatterns; 27 IProject project; 28 29 public RemoveFolderFromIndex(IPath folderPath, char[][] inclusionPatterns, char[][] exclusionPatterns, IProject project, IndexManager manager) { 30 super(project.getFullPath(), manager); 31 this.folderPath = folderPath; 32 this.inclusionPatterns = inclusionPatterns; 33 this.exclusionPatterns = exclusionPatterns; 34 this.project = project; 35 } 36 public boolean execute(IProgressMonitor progressMonitor) { 37 38 if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) return true; 39 40 41 Index index = this.manager.getIndex(this.containerPath, true, false ); 42 if (index == null) return true; 43 ReadWriteMonitor monitor = index.monitor; 44 if (monitor == null) return true; 46 try { 47 monitor.enterRead(); String containerRelativePath = Util.relativePath(this.folderPath, this.containerPath.segmentCount()); 49 String [] paths = index.queryDocumentNames(containerRelativePath); 50 if (paths != null) { 52 if (this.exclusionPatterns == null && this.inclusionPatterns == null) { 53 for (int i = 0, max = paths.length; i < max; i++) { 54 manager.remove(paths[i], this.containerPath); } 56 } else { 57 for (int i = 0, max = paths.length; i < max; i++) { 58 String documentPath = this.containerPath.toString() + '/' + paths[i]; 59 if (!Util.isExcluded(new Path(documentPath), this.inclusionPatterns, this.exclusionPatterns, false)) 60 manager.remove(paths[i], this.containerPath); } 62 } 63 } 64 } catch (IOException e) { 65 if (JobManager.VERBOSE) { 66 Util.verbose("-> failed to remove " + this.folderPath + " from index because of the following exception:", System.err); e.printStackTrace(); 68 } 69 return false; 70 } finally { 71 monitor.exitRead(); } 73 return true; 74 } 75 public String toString() { 76 return "removing " + this.folderPath + " from index " + this.containerPath; } 78 } 79 | Popular Tags |