Skip to main content
A newer version of this page is available. .

ISyntaxHighlightService.Execute() Method

This method is called if the text content of the control is modified.

Namespace: DevExpress.XtraRichEdit.Services

Assembly: DevExpress.RichEdit.v18.2.Core.dll

Declaration

void Execute()

Remarks

Use the Execute method to parse the text into tokens and highlight the document text using the SubDocument.ApplySyntaxHighlight method.

Public Sub Execute() Implements ISyntaxHighlightService.Execute
    Dim newText As String = syntaxEditor.Text
    ' Determine language by file extension.
    Dim ext As String = System.IO.Path.GetExtension(syntaxEditor.Options.DocumentSaveOptions.CurrentFileName)
    Dim lang_ID As ParserLanguageID = ParserLanguage.FromFileExtension(ext)
    ' Do not parse HTML or XML.
    If lang_ID = ParserLanguageID.Html OrElse lang_ID = ParserLanguageID.Xml OrElse lang_ID = ParserLanguageID.None Then
        Return
    End If
    ' Use DevExpress.CodeParser to parse text into tokens.
    Dim tokenHelper As ITokenCategoryHelper = TokenCategoryHelperFactory.CreateHelper(lang_ID)
    Dim highlightTokens As TokenCollection
    highlightTokens = tokenHelper.GetTokens(newText)
    HighlightSyntax(highlightTokens)
End Sub

Public Sub ForceExecute() Implements  ISyntaxHighlightService.ForceExecute
    Execute()
End Sub
See Also