mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-11 02:05: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()) {
|
||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||
monitor.subTask(tu.getElementName());
|
||||
changeTU(tu);
|
||||
try {
|
||||
changeTU(tu);
|
||||
} catch (Throwable e) {
|
||||
CCorePlugin.log(e);
|
||||
if (++errorCount > MAX_ERRORS)
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
monitor.worked(1);
|
||||
}
|
||||
|
||||
|
@ -68,7 +74,13 @@ class PDOMFastHandleDelta extends PDOMFastIndexerJob {
|
|||
while (i.hasNext()) {
|
||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||
monitor.subTask(tu.getElementName());
|
||||
addTU(tu);
|
||||
try {
|
||||
addTU(tu);
|
||||
} catch (Throwable e) {
|
||||
CCorePlugin.log(e);
|
||||
if (++errorCount > MAX_ERRORS)
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
monitor.worked(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,10 @@ public abstract class PDOMFastIndexerJob extends Job {
|
|||
protected final Map fileMap = new HashMap();
|
||||
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) {
|
||||
super("Fast Indexer: " + pdom.getProject().getElementName());
|
||||
this.pdom = pdom;
|
||||
|
@ -74,7 +78,7 @@ public abstract class PDOMFastIndexerJob extends Job {
|
|||
} finally {
|
||||
pdom.releaseWriteLock();
|
||||
}
|
||||
|
||||
|
||||
// Tell the world
|
||||
pdom.fireChange();
|
||||
}
|
||||
|
@ -121,18 +125,18 @@ public abstract class PDOMFastIndexerJob extends Job {
|
|||
shouldVisitNames = true;
|
||||
shouldVisitDeclarations = true;
|
||||
}
|
||||
public int visit(IASTName name) {
|
||||
public int visit(IASTName name) {
|
||||
try {
|
||||
IASTFileLocation nameLoc = name.getFileLocation();
|
||||
if (nameLoc != null)
|
||||
linkage.addName(name, getCachedFile(nameLoc.getFileName()));
|
||||
return PROCESS_CONTINUE;
|
||||
} catch (CoreException e) {
|
||||
} catch (Throwable e) {
|
||||
CCorePlugin.log(e);
|
||||
return PROCESS_ABORT;
|
||||
return ++errorCount > MAX_ERRORS ? PROCESS_ABORT : PROCESS_CONTINUE;
|
||||
}
|
||||
};
|
||||
});;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,8 +72,10 @@ public class PDOMFastReindex extends PDOMFastIndexerJob {
|
|||
monitor.subTask(tu.getElementName());
|
||||
try {
|
||||
addTU(tu);
|
||||
} catch (InterruptedException e) {
|
||||
throw new CoreException(Status.CANCEL_STATUS);
|
||||
} catch (Throwable e) {
|
||||
CCorePlugin.log(e);
|
||||
if (++errorCount > MAX_ERRORS)
|
||||
throw new CoreException(Status.CANCEL_STATUS);
|
||||
}
|
||||
monitor.worked(1);
|
||||
}
|
||||
|
@ -101,8 +103,10 @@ public class PDOMFastReindex extends PDOMFastIndexerJob {
|
|||
monitor.subTask(tu.getElementName());
|
||||
try {
|
||||
addTU(tu);
|
||||
} catch (InterruptedException e) {
|
||||
throw new CoreException(Status.CANCEL_STATUS);
|
||||
} catch (Throwable e) {
|
||||
CCorePlugin.log(e);
|
||||
if (++errorCount > MAX_ERRORS)
|
||||
throw new CoreException(Status.CANCEL_STATUS);
|
||||
}
|
||||
}
|
||||
monitor.worked(1);
|
||||
|
|
|
@ -70,7 +70,13 @@ public class PDOMFullHandleDelta extends PDOMFullIndexerJob {
|
|||
while (i.hasNext()) {
|
||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||
monitor.subTask(tu.getElementName());
|
||||
changeTU(tu);
|
||||
try {
|
||||
changeTU(tu);
|
||||
} catch (Throwable e) {
|
||||
CCorePlugin.log(e);
|
||||
if (++errorCount > MAX_ERRORS)
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
monitor.worked(1);
|
||||
}
|
||||
|
||||
|
@ -78,7 +84,13 @@ public class PDOMFullHandleDelta extends PDOMFullIndexerJob {
|
|||
while (i.hasNext()) {
|
||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||
monitor.subTask(tu.getElementName());
|
||||
addTU(tu);
|
||||
try {
|
||||
addTU(tu);
|
||||
} catch (Throwable e) {
|
||||
CCorePlugin.log(e);
|
||||
if (++errorCount > MAX_ERRORS)
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
monitor.worked(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,10 @@ public abstract class PDOMFullIndexerJob extends Job {
|
|||
|
||||
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) {
|
||||
super("Full Indexer: " + pdom.getProject().getElementName());
|
||||
this.pdom = pdom;
|
||||
|
@ -113,9 +117,9 @@ public abstract class PDOMFullIndexerJob extends Job {
|
|||
linkage.addName(name, file);
|
||||
}
|
||||
return PROCESS_CONTINUE;
|
||||
} catch (CoreException e) {
|
||||
} catch (Throwable e) {
|
||||
CCorePlugin.log(e);
|
||||
return PROCESS_ABORT;
|
||||
return ++errorCount > MAX_ERRORS ? PROCESS_ABORT : PROCESS_CONTINUE;
|
||||
}
|
||||
};
|
||||
});;
|
||||
|
|
|
@ -72,8 +72,10 @@ public class PDOMFullReindex extends PDOMFullIndexerJob {
|
|||
monitor.subTask(tu.getElementName());
|
||||
try {
|
||||
addTU(tu);
|
||||
} catch (InterruptedException e) {
|
||||
throw new CoreException(Status.CANCEL_STATUS);
|
||||
} catch (Throwable e) {
|
||||
CCorePlugin.log(e);
|
||||
if (++errorCount > MAX_ERRORS)
|
||||
throw new CoreException(Status.CANCEL_STATUS);
|
||||
}
|
||||
monitor.worked(1);
|
||||
}
|
||||
|
@ -102,7 +104,9 @@ public class PDOMFullReindex extends PDOMFullIndexerJob {
|
|||
try {
|
||||
addTU(tu);
|
||||
} catch (InterruptedException e) {
|
||||
throw new CoreException(Status.CANCEL_STATUS);
|
||||
CCorePlugin.log(e);
|
||||
if (++errorCount > MAX_ERRORS)
|
||||
throw new CoreException(Status.CANCEL_STATUS);
|
||||
}
|
||||
}
|
||||
monitor.worked(1);
|
||||
|
|
Loading…
Add table
Reference in a new issue