mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-11 10:15:39 +02:00
Improve robustness of the full and fast indexers. If Throwables are detected, the current file or name is skipped. This continues until a maximums is reached in which case the index job is aborted.
This commit is contained in:
parent
9db611cefe
commit
37c5d87fec
6 changed files with 59 additions and 19 deletions
|
@ -60,7 +60,13 @@ class PDOMFastHandleDelta extends PDOMFastIndexerJob {
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||||
monitor.subTask(tu.getElementName());
|
monitor.subTask(tu.getElementName());
|
||||||
|
try {
|
||||||
changeTU(tu);
|
changeTU(tu);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
if (++errorCount > MAX_ERRORS)
|
||||||
|
return Status.CANCEL_STATUS;
|
||||||
|
}
|
||||||
monitor.worked(1);
|
monitor.worked(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +74,13 @@ class PDOMFastHandleDelta extends PDOMFastIndexerJob {
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||||
monitor.subTask(tu.getElementName());
|
monitor.subTask(tu.getElementName());
|
||||||
|
try {
|
||||||
addTU(tu);
|
addTU(tu);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
if (++errorCount > MAX_ERRORS)
|
||||||
|
return Status.CANCEL_STATUS;
|
||||||
|
}
|
||||||
monitor.worked(1);
|
monitor.worked(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,10 @@ public abstract class PDOMFastIndexerJob extends Job {
|
||||||
protected final Map fileMap = new HashMap();
|
protected final Map fileMap = new HashMap();
|
||||||
protected final PDOM pdom;
|
protected final PDOM pdom;
|
||||||
|
|
||||||
|
// Error counter. If we too many errors we bail
|
||||||
|
protected int errorCount;
|
||||||
|
protected final int MAX_ERRORS = 10;
|
||||||
|
|
||||||
public PDOMFastIndexerJob(PDOM pdom) {
|
public PDOMFastIndexerJob(PDOM pdom) {
|
||||||
super("Fast Indexer: " + pdom.getProject().getElementName());
|
super("Fast Indexer: " + pdom.getProject().getElementName());
|
||||||
this.pdom = pdom;
|
this.pdom = pdom;
|
||||||
|
@ -127,12 +131,12 @@ public abstract class PDOMFastIndexerJob extends Job {
|
||||||
if (nameLoc != null)
|
if (nameLoc != null)
|
||||||
linkage.addName(name, getCachedFile(nameLoc.getFileName()));
|
linkage.addName(name, getCachedFile(nameLoc.getFileName()));
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
} catch (CoreException e) {
|
} catch (Throwable e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
return PROCESS_ABORT;
|
return ++errorCount > MAX_ERRORS ? PROCESS_ABORT : PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
});;
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,9 @@ public class PDOMFastReindex extends PDOMFastIndexerJob {
|
||||||
monitor.subTask(tu.getElementName());
|
monitor.subTask(tu.getElementName());
|
||||||
try {
|
try {
|
||||||
addTU(tu);
|
addTU(tu);
|
||||||
} catch (InterruptedException e) {
|
} catch (Throwable e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
if (++errorCount > MAX_ERRORS)
|
||||||
throw new CoreException(Status.CANCEL_STATUS);
|
throw new CoreException(Status.CANCEL_STATUS);
|
||||||
}
|
}
|
||||||
monitor.worked(1);
|
monitor.worked(1);
|
||||||
|
@ -101,7 +103,9 @@ public class PDOMFastReindex extends PDOMFastIndexerJob {
|
||||||
monitor.subTask(tu.getElementName());
|
monitor.subTask(tu.getElementName());
|
||||||
try {
|
try {
|
||||||
addTU(tu);
|
addTU(tu);
|
||||||
} catch (InterruptedException e) {
|
} catch (Throwable e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
if (++errorCount > MAX_ERRORS)
|
||||||
throw new CoreException(Status.CANCEL_STATUS);
|
throw new CoreException(Status.CANCEL_STATUS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,13 @@ public class PDOMFullHandleDelta extends PDOMFullIndexerJob {
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||||
monitor.subTask(tu.getElementName());
|
monitor.subTask(tu.getElementName());
|
||||||
|
try {
|
||||||
changeTU(tu);
|
changeTU(tu);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
if (++errorCount > MAX_ERRORS)
|
||||||
|
return Status.CANCEL_STATUS;
|
||||||
|
}
|
||||||
monitor.worked(1);
|
monitor.worked(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +84,13 @@ public class PDOMFullHandleDelta extends PDOMFullIndexerJob {
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||||
monitor.subTask(tu.getElementName());
|
monitor.subTask(tu.getElementName());
|
||||||
|
try {
|
||||||
addTU(tu);
|
addTU(tu);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
if (++errorCount > MAX_ERRORS)
|
||||||
|
return Status.CANCEL_STATUS;
|
||||||
|
}
|
||||||
monitor.worked(1);
|
monitor.worked(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,10 @@ public abstract class PDOMFullIndexerJob extends Job {
|
||||||
|
|
||||||
protected final PDOM pdom;
|
protected final PDOM pdom;
|
||||||
|
|
||||||
|
// Error count, bail when it gets too high
|
||||||
|
protected int errorCount;
|
||||||
|
protected final int MAX_ERRORS = 10;
|
||||||
|
|
||||||
public PDOMFullIndexerJob(PDOM pdom) {
|
public PDOMFullIndexerJob(PDOM pdom) {
|
||||||
super("Full Indexer: " + pdom.getProject().getElementName());
|
super("Full Indexer: " + pdom.getProject().getElementName());
|
||||||
this.pdom = pdom;
|
this.pdom = pdom;
|
||||||
|
@ -113,9 +117,9 @@ public abstract class PDOMFullIndexerJob extends Job {
|
||||||
linkage.addName(name, file);
|
linkage.addName(name, file);
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
} catch (CoreException e) {
|
} catch (Throwable e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
return PROCESS_ABORT;
|
return ++errorCount > MAX_ERRORS ? PROCESS_ABORT : PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});;
|
});;
|
||||||
|
|
|
@ -72,7 +72,9 @@ public class PDOMFullReindex extends PDOMFullIndexerJob {
|
||||||
monitor.subTask(tu.getElementName());
|
monitor.subTask(tu.getElementName());
|
||||||
try {
|
try {
|
||||||
addTU(tu);
|
addTU(tu);
|
||||||
} catch (InterruptedException e) {
|
} catch (Throwable e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
if (++errorCount > MAX_ERRORS)
|
||||||
throw new CoreException(Status.CANCEL_STATUS);
|
throw new CoreException(Status.CANCEL_STATUS);
|
||||||
}
|
}
|
||||||
monitor.worked(1);
|
monitor.worked(1);
|
||||||
|
@ -102,6 +104,8 @@ public class PDOMFullReindex extends PDOMFullIndexerJob {
|
||||||
try {
|
try {
|
||||||
addTU(tu);
|
addTU(tu);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
if (++errorCount > MAX_ERRORS)
|
||||||
throw new CoreException(Status.CANCEL_STATUS);
|
throw new CoreException(Status.CANCEL_STATUS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue