Table of Contents

Class TypeScriptParser

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 TypeScript language.

[ToolboxBitmap(typeof(TypeScriptParser), "Images.TS.TsParser.Icon.bmp")]
public class TypeScriptParser : SyntaxParser, IComponent, IDisposable, ISyntaxParser, IParser, ILexer, INotify, IUpdate, IImport
Inheritance
TypeScriptParser
Implements
Derived

Examples

Here is how to declare a TypeScriptParser 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.TypeScriptParser();
        var edit = new Alternet.Editor.SyntaxEdit();
        edit.Parent = this;
        edit.Lexer = parser;

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

Here is how to declare a TypeScriptParser 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.TypeScriptParser()
        Dim edit = New Alternet.Editor.SyntaxEdit()
        edit.Parent = Me
        edit.Lexer = parser
        Dim fileName As String = "myfile.ts"

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

Remarks

TypeScriptParser is a non-visual component designed to perform syntax highlighting for TypeScript language. This parser uses the Microsoft TypeScript API and supports full syntax and semantic analysis of the TypeScript and 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 PythonParser:

  • Syntax Highlighting
  • IntelliSense (Code completion)
  • Code Outlining
  • Structure guidelines
  • Formatting a selected block of text or the whole document
  • Finding declarations and references
  • Code Fixes and Code refactoring

Constructors

TypeScriptParser()

Initializes a new instance of the TypeScriptParser class with default TypeScriptProject.

TypeScriptParser(ITypeScriptProject)

Initializes a new instance of the TypeScriptParser class with specified ITypeScriptProject.

Properties

FileName

Gets or sets file name of the file being parsed.

Repository

Gets an IRoslynRepository that holds methods for code completion purposes.

ScriptKind

Gets or sets kind of the source code file being parsed.

Strings

Gets or sets a list of strings to parse.

SuppressedDiagnostics
Tokenizer

Methods

CanFindDeclaration(Point)
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.

CreateTokenizer()
DoCodeCompletion(string, Point, CodeCompletionArgs, CancellationToken, bool)
FindCodeActions(Point, Point, Point, ISyntaxError, bool)

Locates and highlights available code fixes and code refactors for given position in the texts.

FindDeclaration(Point)

Finds the declaration node at given position.

FindReferences(Point)

Locates and highlights references at given position in the text.

FindReferences(Point, IRangeList, bool)

Locates declaration at given position and finds all references to this declaration in the text.

FindReferences(Point, bool)
GetActiveStatementAt(Point)

Gets IRange that corresponds to the statement at specified position.

GetCodeFixes(ISyntaxError, bool)

Retrieves all code fixes available for the given syntax error.

GetCodeRefactors(Point, Point, bool)

Retrieves all applicable refactors at given range.

GetCompletionType(char)

Obtains type of code completion window from specifies char parameter.

GetCurrentChar(int, int)
GetErrorType(DiagnosticCategory)
GetSingleLineComment()

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

GetSmartIndentString(int, bool, bool, int)

Returns indentation string for specified line.

GetStructureGuideLines(IList<IRange>)

Gets list of guide lines.

GetSyntaxErrors(IList<ISyntaxError>)

Retrieves all syntax errors found while analyzing the text.

GetSyntaxErrorsInternal(IList<ISyntaxError>)
GetTextChangesForRefactor(ICodeRefactor, bool)
GetXmlComment()

Represents beginning of XML comment.

HasCodeFixes(ISyntaxError, bool)

When implemented by a class, determines if code fixes are available for a given syntax error.

HasCodeRefactors(Point, Point, bool)

When implemented by a class, determines if code fixes are available for a given syntax error.

HasDocument()
InitDefaultStyles()
InitLexer()
IsCodeCompletionChar(char, byte, ref int)

Returns boolean value indicating that given character initializes a code completion procedure when typing.

IsCommentEndAt(string, string, int)
LoadFile(string, Encoding)

Loads the contents of the specified file with specified encoding.

Outline(IList<IRange>)

Creates outlined sections for parsed text using result of syntax analysis and fills ranges parameter by the collection of the outlined sections.

OutlineInternal(IList<IRange>)
ParseSemanticAsync(CancellationToken)

Performs syntax analysis of specified document.

ParseSyntaxAsync(int, int, CancellationToken)

Performs syntax analysis of specified document.

ParseText(int, int, string, ref StringItemInfo[])

Performs lexical analysis of given text.

PositionChanged(int, int, int, int)

Changes positions of any syntax nodes and its elements located next to the specified position.

Prepare(string, IStringList, ISyntaxTree, bool, PrepareReason)

Sets lines to parse.

ProcessGuideLines(IList<IRange>, IList<NodeData>)
ProcessGuideLinesInternal(IList<IRange>)
RegisterDefaultAssemblies(TechnologyEnvironment)

Adds default system assemblies to be used for Code completion.

RemoveDocumentCommentAt(int)
ReparseSyntax(bool)
ReparseText()

Reparses entire text.

ReparseText(bool, int, int)

Reparses entire text.

Specifies whether parser should perform the task in the separate threadSpecifies first changed line in the source text.Specifies last changed line in the source text.
ReparseTextAsync(int, int)
Reset()

Resets SyntaxParser to the start position.

ResetAutoIndentChars()

Resets AutoIndentChars to the default value.

ResetCodeCompletionChars()

Resets CodeCompletionChars to the default value.

ResetOptions()

Resets Options to the default value.

ResetParseInterval()

Resets ParseInterval to the default value.

ResetScriptKind()

Resets ScriptKind to the default value.

ResetSmartFormatChars()

Resets SmartFormatChars to the default value.

ShouldSerializeAutoIndentChars()

Indicates whether the AutoIndentChars property should be persisted.

ShouldSerializeCodeCompletionChars()

Indicates whether the CodeCompletionChars property should be persisted.

ShouldSerializeOptions()

Indicates whether the Options property should be persisted.

ShouldSerializeParseInterval()

Indicates whether the ParseInterval property should be persisted.

ShouldSerializeScriptKind()

Indicates whether the ScriptKind property should be persisted.

ShouldSerializeSmartFormatChars()

Indicates whether the SmartFormatChars property should be persisted.

SmartFormat(ref Point, bool, int, ITextUndoList, string)

Formats block of text according to the parser rules.

SmartFormat(ref Point, ref Point, bool, int, bool, ITextUndoList)

Formats block of text according to the parser rules.

Start position of the blockEnd position of the blockIndicates whether indentation string should contain spaces or tabsSpecifies number of spaces in tabSpecifies if whole syntax block containing start and end point should be formattedList containing insertion or deletion of text fragments.
StartParsing(string, int, int)

Prepares parser to parse the specified range of the text.

StopParsing()

Aborts parsing process.

Update()

When implemented by a class, updates an object state.

UpdateDocument(bool)
UpdateDocument(string)