Table of Contents

Class XAMLParser

Namespace
Alternet.Syntax.Parsers.XAML
Assembly
Alternet.Syntax.Parsers.XAML.v9.dll

Represents a class that performs syntax and lexical analysis of specified XAML code text.

public class XAMLParser : XmlParser, IComponent, IDisposable, ISyntaxParser, IParser, ILexer, INotify, IUpdate, IImport
Inheritance
XAMLParser
Implements

Examples

Here is how to declare a XAMLParser and handle its events from the C# code:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        var parser = new Alternet.Syntax.Parsers.XAML.XAMLParser();
        var edit = new Alternet.Editor.SyntaxEdit();
        edit.Parent = this;
        edit.Lexer = parser;

        string fileName = "myfile.xaml";
        if (System.IO.File.Exists(fileName))
        {
            parser.FileName = fileName;
            edit.LoadFile(fileName);
        }

        parser.TextReparsed += XAMLParser_TextReparsed;
    }

    private void XAMLParser_TextReparsed(object sender, EventArgs e)
    {
        System.Windows.Forms.MessageBox.Show("text parsed");
    }
}

Here is how to declare a XAMLParser and handle its events from the Visual Basic code:

Partial Public Class Form1
    Inherits Form

    Public Sub New()
        InitializeComponent()
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
        Dim parser = New Alternet.Syntax.Parsers.XAML.XAMLParser()
        Dim edit = New Alternet.Editor.SyntaxEdit()
        edit.Parent = Me
        edit.Lexer = parser
        Dim fileName As String = "myfile.xaml"

        If System.IO.File.Exists(fileName) Then
            parser.FileName = fileName
            edit.LoadFile(fileName)
        End If

        AddHandler parser.TextReparsed, AddressOf XAMLParser_TextReparsed
    End Sub

    Private Sub XAMLParser_TextReparsed(ByVal sender As Object, ByVal e As EventArgs)
        System.Windows.Forms.MessageBox.Show("text parsed")
    End Sub
End Class

Remarks

XAMLParser is a non-visual component designed to perform syntax highlighting for XAML language. This parser supports full syntax analysis of the XAML code. When linked to the SyntaxEdit or TextEditor controls, this parser drives additional features such as code completion, code outlining, code formatting, and underlying syntax errors and warnings.

Here are some of the essential features provided by the XAMLParser:

  • Syntax Highlighting
  • IntelliSense (Code completion)
  • Code Outlining
  • Structure guidelines
  • Formatting a selected block of text or the whole document

Constructors

XAMLParser()

Initializes a new instance of the XAMLParser class with default settings.

Properties

Repository

Gets an IRoslynRepository that holds methods for code completion purposes.

Methods

CodeCompletion(string, StringItemInfo[], Point, CodeCompletionArgs)

Performs code completion for the specified text representing language element.

CreateRepository()

Creates ICodeCompletionRepository to perform code completion functionality for this parser.

GetCompletionType(char)

Obtains type of code completion window from specifies char parameter.

GetLexerStyle(int)
GetNodeForCodeCompletion(ref Point)
GetSmartIndent(int, bool, out bool)

Returns indentation level of specified line.

GetSmartIndentString(int, bool, bool, int)

Returns indentation string for specified line.

InitDefaultStyles()
LexIdent()
ParseParams(ISyntaxNode)
ReparseText()

Reparses entire text.

ReparseText(bool)

Reparses entire text.

Specifies whether parser should perform the task in the separate thread
ResetAutoIndentChars()

Resets AutoIndentChars to the default value.

ResetCodeCompletionChars()

Resets CodeCompletionChars to the default value.

ResetOptions()

Resets Options to the default value.

ShouldSerializeAutoIndentChars()

Indicates whether the SmartFormatChars property should be persisted.

ShouldSerializeCodeCompletionChars()

Indicates whether the CodeCompletionChars property should be persisted.

ShouldSerializeOptions()

Indicates whether the Options property should be persisted.