public boolean execute(IProgressMonitor progressMonitor) { if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) return true; /* ensure no concurrent write access to index */ Index index = this.manager.getIndex( this.containerPath, true /*reuse index file*/, false /*don't create if none*/); if (index == null) return true; ReadWriteMonitor monitor = index.monitor; if (monitor == null) return true; // index got deleted since acquired try { monitor.enterWrite(); // ask permission to write this.manager.saveIndex(index); } catch (IOException e) { if (JobManager.VERBOSE) { Util.verbose( "-> failed to save index " + this.containerPath + " because of the following exception:", System.err); // $NON-NLS-1$ //$NON-NLS-2$ e.printStackTrace(); } return false; } finally { monitor.exitWrite(); // free write lock } return true; }
public boolean execute(IProgressMonitor progressMonitor) { if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) return true; /* ensure no concurrent write access to index */ Index index = this.manager.getIndex( this.containerPath, true, /*reuse index file*/ false /*create if none*/); if (index == null) return true; ReadWriteMonitor monitor = index.monitor; if (monitor == null) return true; // index got deleted since acquired try { monitor.enterRead(); // ask permission to read String containerRelativePath = Util.relativePath(this.folderPath, this.containerPath.segmentCount()); String[] paths = index.queryDocumentNames(containerRelativePath); // all file names belonging to the folder or its subfolders and that are not excluded (see // http://bugs.eclipse.org/bugs/show_bug.cgi?id=32607) if (paths != null) { if (this.exclusionPatterns == null && this.inclusionPatterns == null) { for (int i = 0, max = paths.length; i < max; i++) { manager.remove( paths[i], this.containerPath); // write lock will be acquired by the remove operation } } else { for (int i = 0, max = paths.length; i < max; i++) { String documentPath = this.containerPath.toString() + '/' + paths[i]; if (!Util.isExcluded( new Path(documentPath), this.inclusionPatterns, this.exclusionPatterns, false)) manager.remove( paths[i], this.containerPath); // write lock will be acquired by the remove operation } } } } catch (IOException e) { if (JobManager.VERBOSE) { Util.verbose( "-> failed to remove " + this.folderPath + " from index because of the following exception:", System.err); // $NON-NLS-1$ //$NON-NLS-2$ e.printStackTrace(); } return false; } finally { monitor.exitRead(); // free read lock } return true; }
public boolean execute(IProgressMonitor progressMonitor) { if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) return true; /* ensure no concurrent write access to index */ Index index = this.manager.getIndex( this.containerPath, true, /*reuse index file*/ false /*create if none*/); if (index == null) return true; ReadWriteMonitor monitor = index.monitor; if (monitor == null) return true; // index got deleted since acquired try { monitor.enterWrite(); // ask permission to write index.remove(resourceName); } finally { monitor.exitWrite(); // free write lock } return true; }
public boolean execute(IProgressMonitor progressMonitor) { if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) return true; if (!project.isAccessible()) return true; // nothing to do IResource folder = this.project.getParent().findMember(this.folderPath); if (folder == null || folder.getType() == IResource.FILE) return true; // nothing to do, source folder was removed /* ensure no concurrent write access to index */ Index index = this.manager.getIndex( this.containerPath, true, /*reuse index file*/ true /*create if none*/); if (index == null) return true; ReadWriteMonitor monitor = index.monitor; if (monitor == null) return true; // index got deleted since acquired try { monitor.enterRead(); // ask permission to read final IPath container = this.containerPath; final IndexManager indexManager = this.manager; final SourceElementParser parser = indexManager.getSourceElementParser( JavaCore.create(this.project), null /*requestor will be set by indexer*/); if (this.exclusionPatterns == null && this.inclusionPatterns == null) { folder.accept( new IResourceProxyVisitor() { public boolean visit(IResourceProxy proxy) /* throws CoreException */ { if (proxy.getType() == IResource.FILE) { if (descent.internal.core.util.Util.isJavaLikeFileName(proxy.getName())) indexManager.addSource((IFile) proxy.requestResource(), container, parser); return false; } return true; } }, IResource.NONE); } else { folder.accept( new IResourceProxyVisitor() { public boolean visit(IResourceProxy proxy) /* throws CoreException */ { switch (proxy.getType()) { case IResource.FILE: if (descent.internal.core.util.Util.isJavaLikeFileName(proxy.getName())) { IResource resource = proxy.requestResource(); if (!Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) indexManager.addSource((IFile) resource, container, parser); } return false; case IResource.FOLDER: if (exclusionPatterns != null && inclusionPatterns == null) { // if there are inclusion patterns then we must walk the children if (Util.isExcluded( proxy.requestFullPath(), inclusionPatterns, exclusionPatterns, true)) return false; } } return true; } }, IResource.NONE); } } catch (CoreException e) { if (JobManager.VERBOSE) { Util.verbose( "-> failed to add " + this.folderPath + " to index because of the following exception:", System.err); // $NON-NLS-1$ //$NON-NLS-2$ e.printStackTrace(); } return false; } finally { monitor.exitRead(); // free read lock } return true; }