1 11 package org.eclipse.jdt.internal.core.search.indexing; 12 13 import java.io.IOException ; 14 15 import org.eclipse.core.runtime.IPath; 16 import org.eclipse.core.runtime.IProgressMonitor; 17 import org.eclipse.jdt.internal.core.index.Index; 18 import org.eclipse.jdt.internal.core.search.processing.JobManager; 19 import org.eclipse.jdt.internal.core.util.Util; 20 21 24 public class SaveIndex extends IndexRequest { 25 public SaveIndex(IPath containerPath, IndexManager manager) { 26 super(containerPath, manager); 27 } 28 public boolean execute(IProgressMonitor progressMonitor) { 29 30 if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) return true; 31 32 33 Index index = this.manager.getIndex(this.containerPath, true , false ); 34 if (index == null) return true; 35 ReadWriteMonitor monitor = index.monitor; 36 if (monitor == null) return true; 38 try { 39 monitor.enterWrite(); this.manager.saveIndex(index); 41 } catch (IOException e) { 42 if (JobManager.VERBOSE) { 43 Util.verbose("-> failed to save index " + this.containerPath + " because of the following exception:", System.err); e.printStackTrace(); 45 } 46 return false; 47 } finally { 48 monitor.exitWrite(); } 50 return true; 51 } 52 public String toString() { 53 return "saving index for " + this.containerPath; } 55 } 56 | Popular Tags |