mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 17:35:35 +02:00
Bug 135034 - Handle project deletion while indexing. Cancels all pending and the current task if they are started by the indexer associated with the project.
Also snuck in a change to the menu items for Searching decls and refs, i.e. removed to "All" to match the JDT.
This commit is contained in:
parent
090476da2d
commit
933ecf7e00
8 changed files with 77 additions and 10 deletions
|
@ -48,6 +48,7 @@ import org.eclipse.cdt.core.model.IParent;
|
|||
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMManager;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -1136,6 +1137,8 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
public void deleting(IProject project) {
|
||||
// stop the binary runner for this project
|
||||
removeBinaryRunner(project);
|
||||
// stop indexing jobs for this project
|
||||
CCorePlugin.getPDOMManager().deleting(create(project));
|
||||
}
|
||||
|
||||
}
|
|
@ -19,4 +19,6 @@ public interface IPDOMIndexerTask {
|
|||
*/
|
||||
public void run(IProgressMonitor monitor);
|
||||
|
||||
public IPDOMIndexer getIndexer();
|
||||
|
||||
}
|
||||
|
|
|
@ -36,4 +36,7 @@ public interface IPDOMManager {
|
|||
// Enqueue and indexer sub job
|
||||
public void enqueue(IPDOMIndexerTask subjob);
|
||||
|
||||
// Project being deleted
|
||||
public void deleting(ICProject project);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.pdom;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
|
@ -22,7 +24,12 @@ public class PDOMIndexerJob extends Job {
|
|||
private final PDOMManager manager;
|
||||
|
||||
private LinkedList queue = new LinkedList();
|
||||
private IPDOMIndexerTask currentTask;
|
||||
private boolean isCancelling = false;
|
||||
private Object taskMutex = new Object();
|
||||
|
||||
private IProgressMonitor monitor;
|
||||
|
||||
public PDOMIndexerJob(PDOMManager manager) {
|
||||
super(CCorePlugin.getResourceString("pdom.indexer.name")); //$NON-NLS-1$
|
||||
this.manager = manager;
|
||||
|
@ -30,6 +37,8 @@ public class PDOMIndexerJob extends Job {
|
|||
}
|
||||
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
this.monitor = monitor;
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
String taskName = CCorePlugin.getResourceString("pdom.indexer.task"); //$NON-NLS-1$
|
||||
|
@ -38,10 +47,20 @@ public class PDOMIndexerJob extends Job {
|
|||
fillQueue();
|
||||
while (true) {
|
||||
while (!queue.isEmpty()) {
|
||||
if (monitor.isCanceled())
|
||||
return Status.CANCEL_STATUS;
|
||||
IPDOMIndexerTask task = (IPDOMIndexerTask)queue.removeFirst();
|
||||
task.run(monitor);
|
||||
synchronized (taskMutex) {
|
||||
currentTask = (IPDOMIndexerTask)queue.removeFirst();
|
||||
}
|
||||
currentTask.run(monitor);
|
||||
synchronized (taskMutex) {
|
||||
if (isCancelling) {
|
||||
// TODO chance for confusion here is user cancels
|
||||
// while project is getting deletes.
|
||||
monitor.setCanceled(false);
|
||||
isCancelling = false;
|
||||
taskMutex.notify();
|
||||
} else if (monitor.isCanceled())
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
}
|
||||
if (manager.finishIndexerJob())
|
||||
break;
|
||||
|
@ -58,10 +77,30 @@ public class PDOMIndexerJob extends Job {
|
|||
}
|
||||
|
||||
private void fillQueue() {
|
||||
IPDOMIndexerTask task = manager.getNextTask();
|
||||
while (task != null) {
|
||||
queue.addLast(task);
|
||||
task = manager.getNextTask();
|
||||
synchronized (taskMutex) {
|
||||
IPDOMIndexerTask task = manager.getNextTask();
|
||||
while (task != null) {
|
||||
queue.addLast(task);
|
||||
task = manager.getNextTask();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void cancelJobs(IPDOMIndexer indexer) {
|
||||
synchronized (taskMutex) {
|
||||
for (Iterator i = queue.iterator(); i.hasNext();) {
|
||||
IPDOMIndexerTask task = (IPDOMIndexerTask)i.next();
|
||||
if (task.getIndexer().equals(indexer))
|
||||
i.remove();
|
||||
}
|
||||
if (currentTask != null && currentTask.getIndexer().equals(indexer)) {
|
||||
monitor.setCanceled(true);
|
||||
isCancelling = true;
|
||||
try {
|
||||
taskMutex.wait();
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -304,6 +304,16 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
|
|||
}
|
||||
}
|
||||
|
||||
public void deleting(ICProject project) {
|
||||
// Project is about to be deleted. Stop all indexing tasks for it
|
||||
IPDOMIndexer indexer = getIndexer(project);
|
||||
synchronized (indexerJobMutex) {
|
||||
if (indexerJob != null) {
|
||||
indexerJob.cancelJobs(indexer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Startup the PDOM. This mainly sets us up to handle model
|
||||
* change events.
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
package org.eclipse.cdt.internal.core.pdom.indexer.fast;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||
|
@ -47,6 +48,10 @@ public abstract class PDOMFastIndexerJob implements IPDOMIndexerTask {
|
|||
this.codeReaderFactory = new PDOMCodeReaderFactory(pdom);
|
||||
}
|
||||
|
||||
public IPDOMIndexer getIndexer() {
|
||||
return indexer;
|
||||
}
|
||||
|
||||
protected void addTU(ITranslationUnit tu) throws InterruptedException, CoreException {
|
||||
ILanguage language = tu.getLanguage();
|
||||
if (language == null)
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
package org.eclipse.cdt.internal.core.pdom.indexer.full;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||
|
@ -44,6 +45,10 @@ public abstract class PDOMFullIndexerJob implements IPDOMIndexerTask {
|
|||
this.pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(indexer.getProject());
|
||||
}
|
||||
|
||||
public IPDOMIndexer getIndexer() {
|
||||
return indexer;
|
||||
}
|
||||
|
||||
protected IASTTranslationUnit parse(ITranslationUnit tu) throws CoreException {
|
||||
ILanguage language = tu.getLanguage();
|
||||
if (language == null)
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
###############################################################################
|
||||
|
||||
group.search=S&earch For
|
||||
group.declarations= All Dec&larations
|
||||
group.references= All Re&ferences
|
||||
group.declarations=Dec&larations
|
||||
group.references=Re&ferences
|
||||
|
||||
|
||||
Search.Error.search.title=Search Error
|
||||
|
|
Loading…
Add table
Reference in a new issue