Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Cancel validator when too much errors are present
Cancel validator when too much errors are present [message #1779882] Mon, 15 January 2018 05:06 Go to next message
Eclipse UserFriend
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!

Re: Cancel validator when too much errors are present [message #1779883 is a reply to message #1779882] Mon, 15 January 2018 05:09 Go to previous messageGo to next message
Eclipse UserFriend
have a look at org.eclipse.xtext.ui.validation.DefaultResourceUIValidatorExtension.addMarkers(IFile, Resource, CheckMode, IProgressMonitor)
maybe you should simply return when 1000 errors found
Re: Cancel validator when too much errors are present [message #1779887 is a reply to message #1779883] Mon, 15 January 2018 06:15 Go to previous message
Eclipse UserFriend
Hello Christian,

thanks for your very fast answer =).

I tried it immediately and it works like a charm!
Previous Topic:Build fails after upgrading to xtext 2.13.0
Next Topic:gradle builder xtextbin file
Goto Forum:
  


Current Time: Wed Jul 23 16:33:12 EDT 2025

Powered by FUDForum. Page generated in 0.04292 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top