Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Basic Intellisense

KakCAT edited this page Jun 11, 2016 · 9 revisions

Introduction

ScintillaNET can be extended to display intellisense-like information when used in the context of a scripting tool. By using Reflection techniques and the Jolt.NET library, which has a class that reads documentation from assembly-generated XML files, we can display information about object members in the editor.

The open-source chemical process simulator DWSIM includes a script editor to control flowsheet calculations and mass/energy balances according to the user's needs. It was recently updated to use ScintillaNET, and intellisense was a required feature because of the amount of objects and its members.

The new funcionality was implemented as a set of extenders in VB.NET. This enable usage of the NuGet-distributed library without the need of changing the original source code.

The extender has a procedure to set the editor style to Python language with a few modifications. You can use the extender code in your project very easily, changing the keywords and type descriptors to suit your needs.

Basic Usage

The first thing you'll need to do is to change the keywords and type descriptors to match the ones in your project/application. You must update the keyword and typename parsers in the ShowAutoComplete() and ShowToolTip() procedures. If you're going to use the SetEditorStyle() procedure, you'll also need to update the keywords on it.

Create a private instance of Jolt's XML reader and initialize it before passing it to the extender functions. A good place to initialize it is during the Form's Load event.

Private reader As Jolt.XmlDocCommentReader

reader = New Jolt.XmlDocCommentReader(Assembly.GetExecutingAssembly())

Use the TextChanged event handler for the scintilla editor object to call the autocomplete and tooltip display extenders. That's all.

Private Sub scintilla_TextChanged(sender As Object, e As EventArgs) Handles scintilla.TextChanged
    scintilla.SetColumnMargins()
    scintilla.ShowAutoComplete()
    scintilla.ShowToolTip(reader)
End Sub

When you type some text in the editor and enter the dot (".") character, the autocomplete list will show with a list of corresponding members:

ScintillaNET extenders

After a member name is correctly typed, the corresponding tooltip will be shown:

ScintillaNET extenders

Get the code

View the extender code in VB.NET at https://github.com/DanWBR/dwsim3/blob/c27c2f81cc22ad2cd515515291636692b946788b/DWSIM/Objects/Classes/Extenders/ScintillaExtender.vb

To convert the code to C#, use Telerik's online code converter.