Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 10:06 Go to next message
Alexander Fichtinger is currently offline Alexander FichtingerFriend
Messages: 62
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!

Re: Cancel validator when too much errors are present [message #1779883 is a reply to message #1779882] Mon, 15 January 2018 10:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12388
Registered: July 2009
Senior Member
have a look at org.eclipse.xtext.ui.validation.DefaultResourceUIValidatorExtension.addMarkers(IFile, Resource, CheckMode, IProgressMonitor)
maybe you should simply return when 1000 errors found


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cancel validator when too much errors are present [message #1779887 is a reply to message #1779883] Mon, 15 January 2018 11:15 Go to previous message
Alexander Fichtinger is currently offline Alexander FichtingerFriend
Messages: 62
Registered: January 2013
Member
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: Sun Nov 18 12:23:45 GMT 2018

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

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

Back to the top