public override void Add(SourceUnit sourceUnit, string message, SourceSpan span, int errorCode, Severity severity) { if (severity == Severity.Warning && !ReportWarning(_context.Verbose, errorCode)) { return; } CountError(severity); string path; string codeLine; RubyEncoding encoding; int line = span.Start.Line; if (sourceUnit != null) { path = sourceUnit.Path; using (SourceCodeReader reader = sourceUnit.GetReader()) { if (line > 0) { try { reader.SeekLine(line); codeLine = reader.ReadLine(); } catch (Exception) { codeLine = null; } } else { codeLine = null; } encoding = reader.Encoding != null?RubyEncoding.GetRubyEncoding(reader.Encoding) : RubyEncoding.UTF8; } } else { path = null; codeLine = null; encoding = RubyEncoding.UTF8; } if (severity == Severity.Error || severity == Severity.FatalError) { throw new SyntaxError(message, path, line, span.Start.Column, codeLine); } else { WriteMessage( MutableString.Create(RubyContext.FormatErrorMessage(message, "warning", path, line, span.Start.Column, null), encoding) ); } }
public override void Add(SourceUnit sourceUnit, string message, SourceSpan span, int errorCode, Severity severity) { if (severity == Severity.Warning && !ReportWarning(_context.Verbose, errorCode)) { return; } CountError(severity); string path; string codeLine; int line = span.Start.Line; if (sourceUnit != null) { path = sourceUnit.Path; codeLine = (line > 0) ? sourceUnit.GetCodeLine(line) : null; } else { path = null; codeLine = null; } if (severity == Severity.Error || severity == Severity.FatalError) { throw new SyntaxError(message, path, line, span.Start.Column, codeLine); } else { if (_WriteSite == null) { Interlocked.CompareExchange( ref _WriteSite, CallSite <Func <CallSite, RubyContext, object, object, object> > .Create(RubyCallAction.Make("write", 1)), null ); } message = RubyContext.FormatErrorMessage(message, "warning", path, line, span.Start.Column, null); _WriteSite.Target(_WriteSite, _context, _context.StandardErrorOutput, MutableString.CreateMutable(message)); } }