Class VbParser
Represents a class that performs syntax and lexical analysis of specified Visual Basic.NET code text.
public class VbParser : RoslynParser, IComponent, IDisposable, ISyntaxParser, IParser, ILexer, INotify, IUpdate, IImport
- Inheritance
-
VbParser
- Implements
- Derived
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
VbParserclass with default settings.
- VbParser(IRoslynSolution)
Initializes a new instance of the
VbParserclass with specifiedIRoslynSolution.
Methods
- CreateRepository()
Creates
ICodeCompletionRepositoryto perform code completion functionality for this parser.
- GetCompletionType(char)
Obtains type of code completion window from specifies
charparameter.
- GetSingleLineComment()
Gets the string that represents start symbol of single line comment.
- ResetAutoIndentChars()
Resets
AutoIndentCharsto the default value.
- ResetCodeCompletionChars()
Resets
CodeCompletionCharsto the default value.
- ResetOptions()
Resets
Optionsto the default value.
- ResetSmartFormatChars()
Resets the
SmartFormatCharsto the default value.
- ShouldSerializeAutoIndentChars()
Indicates whether the
SmartFormatCharsproperty should be persisted.
- ShouldSerializeCodeCompletionChars()
Indicates whether the
CodeCompletionCharsproperty should be persisted.
- ShouldSerializeOptions()
Indicates whether the
Optionsproperty should be persisted.
- ShouldSerializeSmartFormatChars()
Indicates whether the
SmartFormatCharsproperty should be persisted.
- SupportsContentDividers()
Indicates whether content dividers are supported.