private string ReportContext(Diagnostic error, string sourceCode, string sourcePath) { if (error.Location.IsInSource && error.Location.SourceTree.FilePath == sourcePath) { var span = error.Location.SourceSpan; return("\r\n" + ScriptPositionReporting.ReportPreviousAndFollowingText(sourceCode, span.Start)); } else { return(""); } }
public void ReportPreviousAndFollowingText() { Assert.AreEqual(" after: \"01234\",\r\n before: \"56789\".", ScriptPositionReporting.ReportPreviousAndFollowingText("0123456789", 5)); }