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

gw.lang.javac.JavaIssueContainer Maven / Gradle / Ivy

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

import gw.lang.IIssue;
import gw.lang.IIssueContainer;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import javax.tools.Diagnostic;
import javax.tools.DiagnosticCollector;
import javax.tools.JavaFileObject;

/**
 */
public class JavaIssueContainer implements IIssueContainer
{
  private DiagnosticCollector _errorHandler;
  private List _issues;

  public JavaIssueContainer( DiagnosticCollector errorHandler )
  {
    _errorHandler = errorHandler;
  }

  @Override
  public List getIssues()
  {
    if( _issues == null )
    {
      List issues = new ArrayList<>();
      if( _errorHandler != null )
      {
        for( Diagnostic diagnostic : _errorHandler.getDiagnostics() )
        {
          JavaIssue issue = new JavaIssue( 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