/// <inheritdoc/> public override object VisitErrorDefinition([NotNull] LGFileParser.ErrorDefinitionContext context) { var lineContent = context.INVALID_LINE().GetText(); if (!string.IsNullOrWhiteSpace(lineContent)) { _templates.Diagnostics.Add(BuildTemplatesDiagnostic(TemplateErrors.SyntaxError($"Unexpected content: '{lineContent}'"), context)); } return(null); }
public override void SyntaxError([NotNull] IRecognizer recognizer, [Nullable] IToken offendingSymbol, int line, int charPositionInLine, [NotNull] string msg, [Nullable] RecognitionException e) { var startPosition = new Position(lineOffset + line, charPositionInLine); var stopPosition = new Position(lineOffset + line, charPositionInLine + offendingSymbol.StopIndex - offendingSymbol.StartIndex + 1); var range = new Range(startPosition, stopPosition); var diagnostic = new Diagnostic(range, TemplateErrors.SyntaxError(msg), DiagnosticSeverity.Error, source); throw new TemplateException(diagnostic.ToString(), new List <Diagnostic>() { diagnostic }); }