Table of Contents

Class VbParser

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

Represents a class that performs syntax and lexical analysis of specified Visual Basic.NET code text.

[ToolboxBitmap(typeof(RoslynParser), "Images.VbParser.Icon.bmp")]
public class VbParser : RoslynParser, IComponent, IDisposable, ISyntaxParser, IParser, ILexer, INotify, IUpdate, IImport
Inheritance
VbParser
Implements

Examples

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

public partial class Form1 : Form
{
    private Alternet.Syntax.Parsers.Roslyn.VbParser parser;

    private void Form1_Load(object sender, EventArgs e)
    {
        var edit = new Alternet.Editor.SyntaxEdit();
        var parser = new Alternet.Syntax.Parsers.Roslyn.VbParser();
        edit.Lexer = parser;
        string fileName = "myfile.vb";
        if (System.IO.File.Exists(fileName))
        {
            parser.FileName = fileName;
            edit.LoadFile(fileName);
        }

        parser.TextReparsed += VbParser_TextReparsed;
    }

    private void VbParser_TextReparsed(object sender, EventArgs e)
    {
        var parser = sender as Alternet.Syntax.Parsers.Roslyn.CsParser;
        parser.FindReferences(new System.Drawing.Point(0, 0));
    }
}

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

Partial Public Class Form1
    Inherits Form

    Private parser As Alternet.Syntax.Parsers.Roslyn.VbParser

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
        Dim edit = New Alternet.Editor.SyntaxEdit()
        Dim parser = New Alternet.Syntax.Parsers.Roslyn.VbParser()
        edit.Lexer = parser
        Dim fileName As String = "myfile.vb"

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

        AddHandler parser.TextReparsed, AddressOf VbParser_TextReparsed
    End Sub

    Private Sub VbParser_TextReparsed(ByVal sender As Object, ByVal e As EventArgs)
        Dim parser = TryCast(sender, Alternet.Syntax.Parsers.Roslyn.CsParser)
        parser.FindReferences(New System.Drawing.Point(0, 0))
    End Sub
End Class

Remarks

VbParser is a non-visual component designed to perform syntax highlighting and provide advanced code editing capabilities for the Visual Basic language. This parser uses the Microsoft Code Analysis (Roslyn) API and performs full syntax and semantic analysis of the Visual Basic code, supporting up to the Visual Basic 11 language specification. When linked to the SyntaxEdit or TextEditor controls, this parser drives additional features such as code completion, code outlining, code formatting, highlighting types in different colors, and underlying syntax and semantic errors and warnings.

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

  • Syntax Highlighting
  • IntelliSense (Code completion)
  • Signature Help (displaying parameter information for methods)
  • Code Outlining
  • Structure guidelines
  • Formatting a selected block of text or the whole document
  • Finding declarations and references

Constructors

VbParser()

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

VbParser(IRoslynSolution)

Initializes a new instance of the VbParser class with specified IRoslynSolution.

Methods

CreateRepository()

Creates ICodeCompletionRepository to perform code completion functionality for this parser.

CreateTokenizer()
GetCompletionType(char)

Obtains type of code completion window from specifies char parameter.

GetSingleLineComment()

Gets the string that represents start symbol of single line comment.

InitLanguage()
OutlineRegions(IList<IRange>, SpanResolver, SyntaxNode, int)
ProcessDividers(IList<int>, SpanResolver, SyntaxNode)
ResetAutoIndentChars()

Resets AutoIndentChars to the default value.

ResetCodeCompletionChars()

Resets CodeCompletionChars to the default value.

ResetOptions()

Resets Options to the default value.

ResetSmartFormatChars()

Resets the SmartFormatChars 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.

ShouldSerializeSmartFormatChars()

Indicates whether the SmartFormatChars property should be persisted.

SupportsContentDividers()

Indicates whether content dividers are supported.