private void ShowErrors(IDocument document) { var errors = GetErrors().ToArray(); var semanticErrors = errors .Where(n => n.Tag == "semantic") .SelectMany(n => n.TokensOnError.Select(m => (m.InStringPosition, m.InStringPosition + m.Name.Length - 1))) .ToArray(); var syntaxErrors = errors .Where(n => n.Tag == "syntax") .SelectMany(n => n.TokensOnError.Select(m => (m.InStringPosition, m.InStringPosition + m.Name.Length - 1))) .ToArray(); var lexicalErrors = errors .Where(n => n.Tag == "lexical") .SelectMany(n => n.TokensOnError.Select(m => (m.InStringPosition, m.InStringPosition + m.Name.Length - 1))) .ToArray(); document.ResetHighlight(); //document.ResetFormat(); document.ApplyHighlight(semanticErrors, new[] { Semantic }, Brushes.GreenYellow); document.ApplyHighlight(syntaxErrors, new[] { Syntax }, Brushes.OrangeRed); document.ApplyHighlight(lexicalErrors, new[] { Lexical }, Brushes.Violet); mainWindow.ErrorPanel.ReplaceErrors(document, errors); }