Table of Contents

Property SyntaxErrors

Namespace
Alternet.Editor.TextSource
Assembly
Alternet.Editor.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 Alternet.Editor;
using Alternet.Editor.TextSource;
using Alternet.Syntax;
using Alternet.Syntax.Parsers.Roslyn;

public partial class Form1 : Form
{
    private TextSource textSource;
    private void Form1_Load(object sender, EventArgs e)
    {
        var syntaxEdit = new SyntaxEdit(this.components);
        textSource = new TextSource(this.components);
        textSource.LoadFile("myfile.txt");
        textSource.Lexer = new CsParser();
        syntaxEdit.Source = this.textSource;
    }

    private void Button_Click(object sender, EventArgs 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 Alternet.Editor
Imports Alternet.Editor.TextSource
Imports Alternet.Syntax
Imports Alternet.Syntax.Parsers.Roslyn

    
Partial Public Class Form1
    Inherits Form

    Private textSource As TextSource

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
        Dim syntaxEdit = New SyntaxEdit(Me.components)
        textSource = New TextSource(Me.components)
        textSource.LoadFile("myfile.txt")
        textSource.Lexer = new CsParser()

        syntaxEdit.Source = Me.textSource
    End Sub

    Private Sub Button_Click(ByVal sender As Object, ByVal e As EventArgs)
        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.