mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Make CodanRunner progress monitor work a bit better (#768)
The progress monitor didn't show which file was being analyzed properly. Also, the work units didn't seem to be counted in a good way because the progress bar would stay stuck at like 1%. The fix in this commit for that is not perfect as it gives equal weight to all resources on a same level until further split into sub monitors. It still works quite a bit better without requiring more heavy changes. Also fix usage of deprecated SubProgressMonitor.
This commit is contained in:
parent
3062cdc8d8
commit
0b7c2d9960
2 changed files with 33 additions and 31 deletions
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %Bundle-Name
|
||||
Bundle-SymbolicName: org.eclipse.cdt.codan.core;singleton:=true
|
||||
Bundle-Version: 4.2.100.qualifier
|
||||
Bundle-Version: 4.2.200.qualifier
|
||||
Bundle-Activator: org.eclipse.cdt.codan.core.CodanCorePlugin
|
||||
Bundle-Vendor: %Bundle-Vendor
|
||||
Require-Bundle: org.eclipse.core.runtime,
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.eclipse.core.resources.IResource;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
/**
|
||||
|
@ -75,43 +75,45 @@ public class CodanRunner {
|
|||
}
|
||||
}
|
||||
int numChildren = children == null ? 0 : children.length;
|
||||
int childWeight = 10;
|
||||
// System.err.println("processing " + resource);
|
||||
monitor.beginTask(NLS.bind(Messages.CodanRunner_Code_analysis_on, resource.getFullPath().toString()),
|
||||
checkers * (1 + numChildren * childWeight));
|
||||
int work = children == null ? checkers : numChildren;
|
||||
SubMonitor subMonitor = SubMonitor.convert(monitor, work);
|
||||
subMonitor.subTask(NLS.bind(Messages.CodanRunner_Code_analysis_on, resource.getFullPath().toString()));
|
||||
try {
|
||||
CheckersTimeStats.getInstance().checkerStart(CheckersTimeStats.ALL);
|
||||
ICheckerInvocationContext context = new CheckerInvocationContext(resource);
|
||||
try {
|
||||
for (IChecker checker : chegistry) {
|
||||
if (monitor.isCanceled())
|
||||
return;
|
||||
if (chegistry.isCheckerEnabled(checker, resource, checkerLaunchMode)) {
|
||||
synchronized (checker) {
|
||||
try {
|
||||
checker.before(resource);
|
||||
CheckersTimeStats.getInstance().checkerStart(checker.getClass().getName());
|
||||
if (checkerLaunchMode == CheckerLaunchMode.RUN_AS_YOU_TYPE) {
|
||||
((IRunnableInEditorChecker) checker).processModel(model, context);
|
||||
} else {
|
||||
checker.processResource(resource, context);
|
||||
if (children == null) {
|
||||
try {
|
||||
for (IChecker checker : chegistry) {
|
||||
if (subMonitor.isCanceled())
|
||||
return;
|
||||
if (chegistry.isCheckerEnabled(checker, resource, checkerLaunchMode)) {
|
||||
synchronized (checker) {
|
||||
try {
|
||||
checker.before(resource);
|
||||
CheckersTimeStats.getInstance().checkerStart(checker.getClass().getName());
|
||||
if (checkerLaunchMode == CheckerLaunchMode.RUN_AS_YOU_TYPE) {
|
||||
((IRunnableInEditorChecker) checker).processModel(model, context);
|
||||
} else {
|
||||
checker.processResource(resource, context);
|
||||
}
|
||||
} catch (OperationCanceledException e) {
|
||||
return;
|
||||
} catch (Throwable e) {
|
||||
CodanCorePlugin.log(e);
|
||||
} finally {
|
||||
CheckersTimeStats.getInstance().checkerStop(checker.getClass().getName());
|
||||
checker.after(resource);
|
||||
}
|
||||
} catch (OperationCanceledException e) {
|
||||
return;
|
||||
} catch (Throwable e) {
|
||||
CodanCorePlugin.log(e);
|
||||
} finally {
|
||||
CheckersTimeStats.getInstance().checkerStop(checker.getClass().getName());
|
||||
checker.after(resource);
|
||||
}
|
||||
}
|
||||
subMonitor.worked(1);
|
||||
}
|
||||
monitor.worked(1);
|
||||
} finally {
|
||||
context.dispose();
|
||||
CheckersTimeStats.getInstance().checkerStop(CheckersTimeStats.ALL);
|
||||
//CheckersTimeStats.getInstance().printStats();
|
||||
}
|
||||
} finally {
|
||||
context.dispose();
|
||||
CheckersTimeStats.getInstance().checkerStop(CheckersTimeStats.ALL);
|
||||
//CheckersTimeStats.getInstance().printStats();
|
||||
}
|
||||
|
||||
if (children != null && (checkerLaunchMode == CheckerLaunchMode.RUN_ON_FULL_BUILD
|
||||
|
@ -119,7 +121,7 @@ public class CodanRunner {
|
|||
for (IResource child : children) {
|
||||
if (monitor.isCanceled())
|
||||
return;
|
||||
processResource(child, null, checkerLaunchMode, new SubProgressMonitor(monitor, childWeight));
|
||||
processResource(child, null, checkerLaunchMode, subMonitor.split(1));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
|
Loading…
Add table
Reference in a new issue