All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gw.lang.gosuc.GosuIssueContainer Maven / Gradle / Ivy

There is a newer version: 1.18.2
Show newest version
package gw.lang.gosuc;

import gw.lang.parser.IParseIssue;
import gw.lang.parser.exceptions.ParseResultsException;
import gw.lang.IIssue;
import gw.lang.IIssueContainer;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 */
public class GosuIssueContainer implements IIssueContainer
{
  private final ParseResultsException _pe;
  private List _issues;

  public GosuIssueContainer( ParseResultsException pe )
  {
    _pe = pe;
  }

  @Override
  public List getIssues()
  {
    if( _issues == null )
    {
      List issues = new ArrayList<>();
      if( _pe != null )
      {
        for( IParseIssue diagnostic : _pe.getParseIssues() )
        {
          GosuIssue issue = new GosuIssue( diagnostic );
          issues.add( issue );
        }
      }
      _issues = issues;
    }

    return _issues;
  }

  @Override
  public List getWarnings()
  {
    return getIssues().stream().filter( issue -> issue.getKind() == IIssue.Kind.Warning ).collect( Collectors.toList() );
  }

  @Override
  public List getErrors()
  {
    return getIssues().stream().filter( issue -> issue.getKind() == IIssue.Kind.Error ).collect( Collectors.toList() );
  }

  @Override
  public boolean isEmpty()
  {
    return getIssues().isEmpty();
  }}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy