using System.Collections; using System.Collections.Generic; namespace Parser.Internal { public class DiagnosticsBag : IEnumerable { internal DiagnosticsBag() { _diagnostics = new List(); } private readonly List _diagnostics; public IReadOnlyCollection Diagnostics => _diagnostics.AsReadOnly(); private void Report(TextSpan span, string message) { var diagnostic = new Diagnostic(span, message); _diagnostics.Add(diagnostic); } internal void ReportUnexpectedEndOfFile(TextSpan span) { Report(span, "Unexpected end of file."); } public IEnumerator GetEnumerator() { return _diagnostics.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } }