Cancel validator when too much errors are present [message #1779882] |
Mon, 15 January 2018 10:06 |
Alexander Fichtinger Messages: 66 Registered: January 2013 |
Member |
|
|
Hey guys,
we would like to limit the validation of the Xtext Validator when there are more than a certain amount of errors in a project.
We want to do this due to performance problems, when there are many errors (> 100 000).
Is there a way to achieve this?
We already tried the following approach:
public class CustomValidator extends ResourceValidatorImpl
{
private List<Issue> issues;
@Override
public List<Issue> validate(final Resource resource, final CheckMode mode, final CancelIndicator monitor)
throws OperationCanceledError
{
return super.validate(resource, mode, new CustomCancelIndicator(monitor));
}
@Override
protected IAcceptor<Issue> createAcceptor(final List<Issue> result)
{
this.issues = result;
return super.createAcceptor(issues);
}
private class CustomCancelIndicator implements CancelIndicator
{
private static final int MAX_CHECKED_ERRORS = 1000;
private final CancelIndicator monitor;
public CustomCancelIndicator(final CancelIndicator monitor)
{
this.monitor = monitor;
}
@Override
public boolean isCanceled()
{
if (monitor.isCanceled())
{
return true;
}
return issues == null
? false
: issues.size() > MAX_CHECKED_ERRORS;
}
}
}
Basically this code does what we want, BUT if there are more than 1000 errors, the validation is cancelled completely. That means that there are no markers at all. But this is not what we want of course.
We want markers for the first 1000 errors, and when there are more errors no markers should be shown.
Thanks in advance for your help!
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03214 seconds