Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2007-02-12 10:07:23 +0000
committerMarkus Schorn2007-02-12 10:07:23 +0000
commitfe15e65401b9e7c8b2c47740ea3a1ed4d64061f1 (patch)
treed23e71ad7d327e1b9f91afa30d55e0b3ff8be2f8
parent75ab77d3111f54d2c9f15f7be58c9e4427fd905c (diff)
downloadorg.eclipse.cdt-fe15e65401b9e7c8b2c47740ea3a1ed4d64061f1.tar.gz
org.eclipse.cdt-fe15e65401b9e7c8b2c47740ea3a1ed4d64061f1.tar.xz
org.eclipse.cdt-fe15e65401b9e7c8b2c47740ea3a1ed4d64061f1.zip
Allow to cancel indexer while collecting files.
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java25
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastHandleDelta.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastReindex.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullHandleDelta.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullReindex.java3
5 files changed, 29 insertions, 12 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java
index ef11e260d85..4deb4288058 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java
@@ -59,14 +59,20 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
private final Collection fHeaders;
private final boolean fAllFiles;
private final Collection fSources;
+ private final IProgressMonitor fProgressMonitor;
- private TranslationUnitCollector(Collection sources, Collection headers, boolean allFiles) {
+ private TranslationUnitCollector(Collection sources, Collection headers, boolean allFiles,
+ IProgressMonitor pm) {
fHeaders = headers;
fAllFiles = allFiles;
fSources = sources;
+ fProgressMonitor= pm;
}
public boolean visit(ICElement element) throws CoreException {
+ if (fProgressMonitor.isCanceled()) {
+ return false;
+ }
switch (element.getElementType()) {
case ICElement.C_UNIT:
ITranslationUnit tu = (ITranslationUnit)element;
@@ -118,14 +124,15 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
return (trace != null && trace.equalsIgnoreCase(value));
}
- protected void processDelta(ICElementDelta delta, Collection added, Collection changed, Collection removed) throws CoreException {
+ protected void processDelta(ICElementDelta delta, Collection added, Collection changed, Collection removed,
+ IProgressMonitor pm) throws CoreException {
boolean allFiles= getIndexAllFiles();
int flags = delta.getFlags();
if ((flags & ICElementDelta.F_CHILDREN) != 0) {
ICElementDelta[] children = delta.getAffectedChildren();
for (int i = 0; i < children.length; ++i) {
- processDelta(children[i], added, changed, removed);
+ processDelta(children[i], added, changed, removed, pm);
}
}
@@ -155,20 +162,22 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
case ICElement.C_CCONTAINER:
ICContainer folder= (ICContainer) element;
if (delta.getKind() == ICElementDelta.ADDED) {
- collectSources(folder, added, added, allFiles);
+ collectSources(folder, added, added, allFiles, pm);
}
break;
}
}
- private void collectSources(ICContainer container, final Collection sources, final Collection headers, final boolean allFiles) throws CoreException {
- container.accept(new TranslationUnitCollector(sources, headers, allFiles));
+ private void collectSources(ICContainer container, Collection sources, Collection headers, boolean allFiles,
+ IProgressMonitor pm) throws CoreException {
+ container.accept(new TranslationUnitCollector(sources, headers, allFiles, pm));
}
- protected void collectSources(ICProject project, final Collection sources, final Collection headers, final boolean allFiles) throws CoreException {
+ protected void collectSources(ICProject project, Collection sources, Collection headers, boolean allFiles,
+ IProgressMonitor pm) throws CoreException {
fMessage= MessageFormat.format(Messages.PDOMIndexerTask_collectingFilesTask, new Object[]{project.getElementName()});
- project.accept(new TranslationUnitCollector(sources, headers, allFiles));
+ project.accept(new TranslationUnitCollector(sources, headers, allFiles, pm));
}
protected void removeTU(IWritableIndex index, ITranslationUnit tu, int readlocks) throws CoreException, InterruptedException {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastHandleDelta.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastHandleDelta.java
index cc61aa95d7a..baed231bc8b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastHandleDelta.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastHandleDelta.java
@@ -21,6 +21,7 @@ import org.eclipse.cdt.core.model.ICElementDelta;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
class PDOMFastHandleDelta extends PDOMFastIndexerJob {
@@ -29,7 +30,7 @@ class PDOMFastHandleDelta extends PDOMFastIndexerJob {
public PDOMFastHandleDelta(PDOMFastIndexer indexer, ICElementDelta delta) throws CoreException {
super(indexer);
- processDelta(delta, changed, changed, removed);
+ processDelta(delta, changed, changed, removed, new NullProgressMonitor());
fTotalSourcesEstimate= changed.size() + removed.size();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastReindex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastReindex.java
index 9f31ee920f9..43291da9d9e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastReindex.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastReindex.java
@@ -34,7 +34,12 @@ class PDOMFastReindex extends PDOMFastIndexerJob {
boolean allFiles= getIndexAllFiles();
List sources= new ArrayList();
List headers= new ArrayList();
- collectSources(indexer.getProject(), sources, allFiles ? headers : null, allFiles);
+ collectSources(indexer.getProject(), sources,
+ allFiles ? headers : null, allFiles, monitor);
+
+ if (monitor.isCanceled()) {
+ return;
+ }
fTotalSourcesEstimate= sources.size() + headers.size();
setupIndexAndReaderFactory();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullHandleDelta.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullHandleDelta.java
index aa3a207c703..e64f2971756 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullHandleDelta.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullHandleDelta.java
@@ -21,6 +21,7 @@ import org.eclipse.cdt.core.model.ICElementDelta;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
/**
* @author Doug Schaefer
@@ -33,7 +34,7 @@ class PDOMFullHandleDelta extends PDOMFullIndexerJob {
public PDOMFullHandleDelta(PDOMFullIndexer indexer, ICElementDelta delta) throws CoreException {
super(indexer);
- processDelta(delta, changed, changed, removed);
+ processDelta(delta, changed, changed, removed, new NullProgressMonitor());
fTotalSourcesEstimate= changed.size() + removed.size();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullReindex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullReindex.java
index 19ca583cdbd..d658a9678bd 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullReindex.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/full/PDOMFullReindex.java
@@ -37,7 +37,8 @@ class PDOMFullReindex extends PDOMFullIndexerJob {
List/*<ITranslationUnit>*/ sources= new ArrayList/*<ITranslationUnit>*/();
List/*<ITranslationUnit>*/ headers= new ArrayList/*<ITranslationUnit>*/();
- collectSources(indexer.getProject(), sources, allFiles ? headers : null, allFiles);
+ collectSources(indexer.getProject(), sources,
+ allFiles ? headers : null, allFiles, monitor);
fTotalSourcesEstimate= sources.size() + headers.size();
setupIndexAndReaderFactory();

Back to the top