Table of Contents

Property SyntaxErrors

Namespace
Alternet.Editor.Wpf
Assembly
Alternet.Editor.Wpf.v9.dll

SyntaxErrors

Represents a syntax errors collection.

[Browsable(false)]
public ISyntaxErrors SyntaxErrors { get; }

Property Value

ISyntaxErrors

Examples

Here is how to use a SyntaxErrors in the C# code:

using System;
using System.Windows;
using Alternet.Editor.Wpf;
using Alternet.Syntax;
using Alternet.Syntax.Parsers.Roslyn;

public partial class MainWindow : Window
{
    private TextSource textSource;
    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        var textEdit1 = new TextEditor();
        textSource = new TextSource();
        textSource.LoadFile("myfile.txt");
        textSource.Lexer = new CsParser();

        textEdit1.Source = this.textSource;
    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        foreach (ISyntaxError syntaxError in textSource.SyntaxErrors)
        {
            Console.WriteLine(string.Format("Error Code: {0}, Error Name: {1}, Error Description: {2}, Error Position: {3}, ", syntaxError.ErrorCode, syntaxError.Name, syntaxError.Description, syntaxError.Position));
        }
    }
}

Here is how to use a SyntaxErrors in the Visual Basic code:

Imports System
Imports System.Windows
Imports Alternet.Editor.Wpf
Imports Alternet.Syntax
Imports Alternet.Syntax.Parsers.Roslyn

Partial Public Class MainWindow
    Inherits Window

    Private textSource As TextSource

    Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
        Dim textEdit1 = New TextEditor()
        textSource = New TextSource()
        textSource.LoadFile("myfile.txt")
        textSource.Lexer = New CsParser()

        textEdit1.Source = Me.textSource
    End Sub

    Private Sub Button_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
        For Each syntaxError As ISyntaxError In textSource.SyntaxErrors
            Console.WriteLine(String.Format("Error Code: {0}, Error Name: {1}, Error Description: {2}, Error Position: {3}, ", syntaxError.ErrorCode, syntaxError.Name, syntaxError.Description, syntaxError.Position))
        Next
    End Sub
End Class

Remarks

SyntaxErrors represents a list of syntax errors associated with the linked Lexer object, when it performs a syntax analysis of the text.