Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2007-02-28 13:45:25 +0000
committerMarkus Schorn2007-02-28 13:45:25 +0000
commitae557bd28159c4f69636b4dc0c6133cfe241e234 (patch)
tree6286fc96afa1246c8a158bba1c3bbc2248047f78
parent1d087b260fd010ba06fb07bc5b917f92d7050a28 (diff)
downloadorg.eclipse.cdt-ae557bd28159c4f69636b4dc0c6133cfe241e234.tar.gz
org.eclipse.cdt-ae557bd28159c4f69636b4dc0c6133cfe241e234.tar.xz
org.eclipse.cdt-ae557bd28159c4f69636b4dc0c6133cfe241e234.zip
Indexer: Minor improvement of progress reporting.
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/IndexerProgress.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMIndexerJob.java17
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java41
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMRebuildTask.java20
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMResourceDeltaTask.java41
5 files changed, 64 insertions, 60 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/IndexerProgress.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/IndexerProgress.java
index fa108a9a640..19a7192d1e8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/IndexerProgress.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/IndexerProgress.java
@@ -16,6 +16,7 @@ public class IndexerProgress {
public int fTotalSourcesEstimate;
public int fCompletedHeaders;
public int fCompletedSources;
+ public int fTimeEstimate;
public String fMonitorDetail;
public IndexerProgress() {
@@ -32,4 +33,8 @@ public class IndexerProgress {
public int getRemainingSources() {
return fTotalSourcesEstimate-fCompletedSources;
}
+
+ public int getTimeEstimate() {
+ return fTotalSourcesEstimate > 0 ? fTotalSourcesEstimate : fTimeEstimate;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMIndexerJob.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMIndexerJob.java
index 6ee12781549..f4b145af192 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMIndexerJob.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMIndexerJob.java
@@ -17,7 +17,6 @@ import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
@@ -26,8 +25,9 @@ import org.eclipse.core.runtime.jobs.Job;
*
*/
public class PDOMIndexerJob extends Job {
-
- private static final int TOTAL_MONITOR_WORK = 100000;
+ private static final int PROGRESS_UPDATE_INTERVAL = 500;
+ private static final int TOTAL_MONITOR_WORK = 1000;
+
private final PDOMManager pdomManager;
private IPDOMIndexerTask currentTask;
private boolean cancelledByManager= false;
@@ -42,8 +42,6 @@ public class PDOMIndexerJob extends Job {
}
protected IStatus run(IProgressMonitor monitor) {
- long start = System.currentTimeMillis();
-
fMonitor = monitor;
String taskName = CCorePlugin.getResourceString("pdom.indexer.task"); //$NON-NLS-1$
monitor.beginTask(taskName, TOTAL_MONITOR_WORK);
@@ -57,7 +55,6 @@ public class PDOMIndexerJob extends Job {
public void setCanceled(boolean cancelled) {
fMonitor.setCanceled(cancelled);
}
-
};
synchronized(taskMutex) {
currentTask= null;
@@ -78,12 +75,6 @@ public class PDOMIndexerJob extends Job {
}
}
while (currentTask != null);
-
- String showTimings = Platform.getDebugOption(CCorePlugin.PLUGIN_ID
- + "/debug/pdomtimings"); //$NON-NLS-1$
- if (showTimings != null && showTimings.equalsIgnoreCase("true")) //$NON-NLS-1$
- System.out.println("PDOM Indexer Job Time: " + (System.currentTimeMillis() - start)); //$NON-NLS-1$
-
return Status.OK_STATUS;
}
catch (RuntimeException e) {
@@ -117,7 +108,7 @@ public class PDOMIndexerJob extends Job {
while(!m.isCanceled() && !targetMonitor.isCanceled()) {
currentTick= pdomManager.getMonitorMessage(targetMonitor, currentTick, TOTAL_MONITOR_WORK);
try {
- Thread.sleep(350);
+ Thread.sleep(PROGRESS_UPDATE_INTERVAL);
} catch (InterruptedException e) {
return Status.CANCEL_STATUS;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java
index f32c43673ec..a468dd6b545 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java
@@ -368,10 +368,8 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
else {
if (fCurrentTask != null) {
IndexerProgress info= fCurrentTask.getProgressInformation();
- if (info != null) {
- fCompletedSources+= info.fCompletedSources;
- fCompletedHeaders+= info.fCompletedHeaders;
- }
+ fCompletedSources+= info.fCompletedSources;
+ fCompletedHeaders+= info.fCompletedHeaders;
}
result= fCurrentTask= (IPDOMIndexerTask)fTaskQueue.removeFirst();
}
@@ -601,7 +599,8 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
}
public boolean joinIndexer(int waitMaxMillis, IProgressMonitor monitor) {
- monitor.beginTask(Messages.PDOMManager_JoinIndexerTask, 1000);
+ final int totalTicks = 1000;
+ monitor.beginTask(Messages.PDOMManager_JoinIndexerTask, totalTicks);
long limit= System.currentTimeMillis()+waitMaxMillis;
try {
int currentTicks= 0;
@@ -609,7 +608,7 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
if (monitor.isCanceled()) {
return false;
}
- currentTicks= getMonitorMessage(monitor, currentTicks, 1000);
+ currentTicks= getMonitorMessage(monitor, currentTicks, totalTicks);
synchronized(fTaskQueueMutex) {
if (isIndexerIdle()) {
return true;
@@ -643,33 +642,26 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
int remainingSources= 0;
int completedSources= 0;
int completedHeaders= 0;
- int unknown= 0;
+ int totalEstimate= 0;
String detail= null;
IndexerProgress info;
synchronized (fTaskQueueMutex) {
completedHeaders= fCompletedHeaders;
completedSources= fCompletedSources;
+ totalEstimate= fCompletedHeaders+fCompletedSources;
for (Iterator iter = fTaskQueue.iterator(); iter.hasNext();) {
IPDOMIndexerTask task = (IPDOMIndexerTask) iter.next();
info= task.getProgressInformation();
- if (info == null) {
- unknown++;
- }
- else {
- remainingSources+= info.getRemainingSources();
- }
+ remainingSources+= info.getRemainingSources();
+ totalEstimate+= info.getTimeEstimate();
}
if (fCurrentTask != null) {
info= fCurrentTask.getProgressInformation();
- if (info == null) {
- unknown++;
- }
- else {
- remainingSources+= info.getRemainingSources();
- completedHeaders+= info.fCompletedHeaders;
- completedSources+= info.fCompletedSources;
- detail= info.fMonitorDetail;
- }
+ remainingSources+= info.getRemainingSources();
+ completedHeaders+= info.fCompletedHeaders;
+ completedSources+= info.fCompletedSources;
+ detail= info.fMonitorDetail;
+ totalEstimate+= info.getTimeEstimate();
}
}
@@ -682,9 +674,8 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
}
monitor.subTask(msg);
- totalSources+= unknown*1000;
- if (completedSources > 0 && totalSources >= completedSources) {
- int newTick= completedSources*base/totalSources;
+ if (completedSources > 0 && totalEstimate >= completedSources) {
+ int newTick= completedSources*base/totalEstimate;
if (newTick > currentTicks) {
monitor.worked(newTick-currentTicks);
return newTick;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMRebuildTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMRebuildTask.java
index 31471148368..7dd000b228e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMRebuildTask.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMRebuildTask.java
@@ -25,18 +25,27 @@ import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
import org.eclipse.cdt.internal.core.pdom.IndexerProgress;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osgi.util.NLS;
public class PDOMRebuildTask implements IPDOMIndexerTask {
private static final String TRUE= String.valueOf(true);
private static final ITranslationUnit[] NO_TUS = new ITranslationUnit[0];
- private IPDOMIndexer fIndexer;
- private IPDOMIndexerTask fDelegate;
+ private final IPDOMIndexer fIndexer;
+ private final IndexerProgress fProgress;
+ private volatile IPDOMIndexerTask fDelegate;
public PDOMRebuildTask(IPDOMIndexer indexer) {
fIndexer= indexer;
+ fProgress= createProgress(indexer.getProject().getElementName());
}
+ private IndexerProgress createProgress(String prjName) {
+ IndexerProgress progress= new IndexerProgress();
+ progress.fTimeEstimate= 1000;
+ progress.fMonitorDetail= NLS.bind(Messages.PDOMIndexerTask_collectingFilesTask, prjName);
+ return progress;
+ }
public IPDOMIndexer getIndexer() {
return fIndexer;
@@ -73,7 +82,7 @@ public class PDOMRebuildTask implements IPDOMIndexerTask {
}
}
- private void createDelegate(ICProject project, IProgressMonitor monitor) throws CoreException {
+ private synchronized void createDelegate(ICProject project, IProgressMonitor monitor) throws CoreException {
boolean allFiles= TRUE.equals(fIndexer.getProperty(IndexerPreferences.KEY_INDEX_ALL_FILES));
List list= new ArrayList();
TranslationUnitCollector collector= new TranslationUnitCollector(list, allFiles, monitor);
@@ -83,8 +92,7 @@ public class PDOMRebuildTask implements IPDOMIndexerTask {
}
- public IndexerProgress getProgressInformation() {
- return fDelegate != null ? fDelegate.getProgressInformation() : null;
+ public synchronized IndexerProgress getProgressInformation() {
+ return fDelegate != null ? fDelegate.getProgressInformation() : fProgress;
}
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMResourceDeltaTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMResourceDeltaTask.java
index d92b9ae8b49..136f9c3db1f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMResourceDeltaTask.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMResourceDeltaTask.java
@@ -17,6 +17,7 @@ import java.util.List;
import org.eclipse.cdt.core.dom.IPDOMIndexer;
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
+import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICContainer;
import org.eclipse.cdt.core.model.ICElement;
@@ -30,23 +31,33 @@ import org.eclipse.core.runtime.NullProgressMonitor;
public class PDOMResourceDeltaTask implements IPDOMIndexerTask {
private static final String TRUE = String.valueOf(true);
- private IPDOMIndexer fIndexer;
- private boolean fAllFiles;
- private IPDOMIndexerTask fDelegate;
+ final private IPDOMIndexer fIndexer;
+ final private boolean fAllFiles;
+ final private IPDOMIndexerTask fDelegate;
+ final private IndexerProgress fProgress;
public PDOMResourceDeltaTask(IPDOMIndexer indexer, ICElementDelta delta) throws CoreException {
fIndexer= indexer;
+ fProgress= new IndexerProgress();
fAllFiles= TRUE.equals(getIndexer().getProperty(IndexerPreferences.KEY_INDEX_ALL_FILES));
- List a= new ArrayList();
- List c= new ArrayList();
- List r= new ArrayList();
-
- processDelta(delta, a, c, r, new NullProgressMonitor());
- if (!a.isEmpty() || !c.isEmpty() || !r.isEmpty()) {
- ITranslationUnit[] aa= (ITranslationUnit[]) a.toArray(new ITranslationUnit[a.size()]);
- ITranslationUnit[] ca= (ITranslationUnit[]) c.toArray(new ITranslationUnit[c.size()]);
- ITranslationUnit[] ra= (ITranslationUnit[]) r.toArray(new ITranslationUnit[r.size()]);
- fDelegate= indexer.createTask(aa, ca, ra);
+ if (!IPDOMManager.ID_NO_INDEXER.equals(fIndexer.getID())) {
+ List a= new ArrayList();
+ List c= new ArrayList();
+ List r= new ArrayList();
+
+ processDelta(delta, a, c, r, new NullProgressMonitor());
+ if (!a.isEmpty() || !c.isEmpty() || !r.isEmpty()) {
+ ITranslationUnit[] aa= (ITranslationUnit[]) a.toArray(new ITranslationUnit[a.size()]);
+ ITranslationUnit[] ca= (ITranslationUnit[]) c.toArray(new ITranslationUnit[c.size()]);
+ ITranslationUnit[] ra= (ITranslationUnit[]) r.toArray(new ITranslationUnit[r.size()]);
+ fDelegate= indexer.createTask(aa, ca, ra);
+ }
+ else {
+ fDelegate= null;
+ }
+ }
+ else {
+ fDelegate= null;
}
}
@@ -90,7 +101,6 @@ public class PDOMResourceDeltaTask implements IPDOMIndexerTask {
}
break;
}
-
}
private void collectSources(ICContainer container, Collection sources, IProgressMonitor pm) throws CoreException {
@@ -108,11 +118,10 @@ public class PDOMResourceDeltaTask implements IPDOMIndexerTask {
}
public IndexerProgress getProgressInformation() {
- return fDelegate == null ? null : fDelegate.getProgressInformation();
+ return fDelegate != null ? fDelegate.getProgressInformation() : fProgress;
}
public boolean isEmpty() {
return fDelegate == null;
}
-
}

Back to the top