Proper way to implement cancellable validators/validators occasionally running "forever" [message #1771318] |
Thu, 24 August 2017 01:43 |
John Ruud Messages: 17 Registered: July 2009 |
Junior Member |
|
|
Hi, we have implemented various validators, typically based on: org.eclipse.wst.xml.core.internal.validation.eclipse.Validator.
In most cases users are able to quickly cancel validation by pressing the red 'Cancel Operation' button in the progress dialog. However, in rare cases I observe that multiple individual validators are cancelled, while many others are still running, and validation ends up taking a very long time (sometimes 10+ minutes, or even worse).
Does the following validator cancellation code look reasonable, or is there a better way? Not sure what the root cause of the long running validation sessions is,
while it might be related to switching of workspaces, and validation possibly being triggered by multiple-multiple resource change events rather than just one.
@Override
public ValidationResult validate(IResource resource, int kind, ValidationState valState, IProgressMonitor monitor) {
ValidationResult vr = super.validate(resource, kind, valState, monitor);
if (monitor != null && monitor.isCanceled()) {
vr.setCanceled(true);
vr.setSuspendValidation(resource.getProject()); // also suspend validation for project
}
}
|
|
|
|
Powered by
FUDForum. Page generated in 0.03507 seconds