Class JavaScriptParser
- Namespace
- Alternet.Syntax.Parsers.TypeScript
- Assembly
- Alternet.Syntax.Parsers.TypeScript.v9.dll
Represents properties and methods to perform syntax analysis of the text intended to use for JavaScript language.
[ToolboxBitmap(typeof(JavaScriptParser), "Images.TS.JsParser.Icon.bmp")]
public class JavaScriptParser : TypeScriptParser, IComponent, IDisposable, ISyntaxParser, IParser, ILexer, INotify, IUpdate, IImport
- Inheritance
-
JavaScriptParser
- Implements
Examples
Here is how to declare a JavaScriptParser and assign it to the edit control 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.TypeScript.JavaScriptParser();
var edit = new Alternet.Editor.SyntaxEdit();
edit.Parent = this;
edit.Lexer = parser;
string fileName = "myfile.js";
if (System.IO.File.Exists(fileName))
{
parser.FileName = fileName;
edit.LoadFile(fileName);
}
}
}
Here is how to declare a JavaScriptParser and assign it to the edit control 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.TypeScript.JavaScriptParser()
Dim edit = New Alternet.Editor.SyntaxEdit()
edit.Parent = Me
edit.Lexer = parser
Dim fileName As String = "myfile.js"
If System.IO.File.Exists(fileName) Then
parser.FileName = fileName
edit.LoadFile(fileName)
End If
End Sub
End Class
Remarks
JavaScriptParser is a non-visual component designed to perform syntax highlighting and provide advanced code editing capabilities for JavaScript language. This parser uses Microsoft TypeScript APIs and performs full syntax and code analysis on the JavaScript code. 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 JavaScriptParser:
- Syntax Highlighting
- IntelliSense (Code completion)
- Code Outlining
- Structure guidelines
- Formatting a selected block of text or the whole document
- Finding declarations and references
Constructors
- JavaScriptParser()
Initializes a new instance of the
JavaScriptParser
class with defaultTypeScriptProject
.
- JavaScriptParser(ITypeScriptProject)
Initializes a new instance of the
JavaScriptParser
class with specifiedITypeScriptProject
.
Methods
- CreateRepository()
Creates
ICodeCompletionRepository
to perform code completion functionality for this parser.
- ResetScriptKind()
Resets
ScriptKind
to the default value.
- ShouldSerializeScriptKind()
Indicates whether the
ScriptKind
property should be persisted.