Indent Provider
An indent provider enables support for smart indent features when pressing ENTER.
The Indent Providers topic talks about indent providers in general and how to register them as a "feature" language service.
The VBIndentProvider class is the default implementation of an IIndentProvider service for this language.
Feature Summary
Smart Indent
The built-in indent provider will attempt to properly indent lines inside the current block scope. For instance, pressing ENTER after a Sub
signature will cause the next line to be indented by one tab stop.
Typed Characters
When a space is typed after certain keywords such as End
, Next
, etc., the line will be examined to see if it should be outdented.
Registering with a Syntax Language
Any object that implements IIndentProvider can be associated with a syntax language by registering it as an IIndentProvider service on the language.
The VBSyntaxLanguage class automatically registers a VBIndentProvider with itself when it is created, so normally indent providers never need to be set on a Visual Basic language unless a custom one is made.
This code creates a custom indent provider (defined in a make-believe CustomVBIndentProvider
class) and registers it with the syntax language that is already declared in the language
variable:
language.RegisterIndentProvider(new CustomVBIndentProvider());
Note
The SyntaxLanguageExtensions.RegisterIndentProvider method in the code snippet above is a helper extension method that gets added to ISyntaxLanguage objects when the ActiproSoftware.Text
namespace is imported. See the Service Locator Architecture topic for details on registering and retrieving various service object instances, both via extension methods and generically, as there are some additional requirements for using the extension methods.
Disabling the Functionality
Since this feature is installed as a "feature" service on the language and is installed on VBSyntaxLanguage by default, it can be disabled by uninstalling the service from the language.