public static Diagnostic CreateDiagnostic(SourceText sourceText, [CanBeNull] IToken offendingSymbol, int line, int charPositionInLine, string msg) { if (offendingSymbol != null) { var textExtent = TextExtent.FromBounds(start: offendingSymbol.StartIndex, end: offendingSymbol.StopIndex + 1); var location = sourceText.GetLocation(textExtent); return(CreateDiagnostic(msg, location)); } return(CreateDiagnostic(sourceText: sourceText, line: line, charPositionInLine: charPositionInLine, msg: msg)); }