🚀 BooST - Structured Text Language Server Extension
Description
The Structured Text Language Server Extension (BooST) provides modern development tools for the Structured Text (ST) programming language according to IEC 61131-3, specifically designed for use with B&R Automation Studio. This extension enables efficient writing, validation, and navigation of ST code in Visual Studio Code.
How to Use
- Install the Extension: Search for "BooST" in the Visual Studio Code marketplace and install it.
- Open a Workspace: Open the folder "Logical" of your B&R project in Visual Studio Code.
- Add folder to Workspace: Open the folder "Temp\Includes\AS_TempDecl" to support mapp components.
- Set file encoding: Open User Settings JSON and set file encoding to
windows1252:
"[st]": {
"files.encoding": "windows1252"
}
.st – Structured Text files
.var – Variable declarations
.typ – Type declarations
.fun – Function and function block declarations
Features
- Syntax Highlighting: Automatic color highlighting for keywords, variables, and comments.
- Autocomplete: Smart code completion for variables, functions, and keywords.
- Real-Time Error Detection: Early detection of syntax and type errors while coding.
- Datatype Range Validation: Validates literal values against the target datatype's value range.
- Deprecation Warnings: Mark a function or function block as deprecated with an
@deprecated comment placed directly above its declaration (e.g. (*@deprecated since version 2.0*)); usages are flagged in the editor.
- Go to Definition: Quickly navigate to variable and function declarations.
- Go to Implementation: Quickly navigate to the implementation.
- Go to Type Definition: Navigate from a variable to the declaration of its type, across files.
- Find All References: Display all occurrences of a symbol throughout the project.
- Rename Symbols: Consistently rename variables and functions across the codebase.
- Hover Information: Show type information and comments when hovering over variables.
- Code Formatting: Automatically format ST code for improved readability.
- Code Snippets: Predefined code snippets for common structures and patterns.
- Signature help: Display function signatures and parameter information.
- State Machine Diagram (Beta): Visualize CASE-based state machines as interactive diagrams. Transition functions can be configured via the extension settings.
- Lint Rules: Enforce variable name prefixes per project, with a Quick Fix (see below).
Lint Rules
Lint rules are off until a project turns them on. Create a .boost/lint.json next to your .apj (or in any parent folder, the nearest one applies):
{
"ignores": ["Logical/Libraries/**"],
"rules": {
"variable-prefix-convention": ["warning", {
"scope": { "global": "g_" },
"form": { "ARRAY": "a", "REFERENCE": "r" },
"type": { "BOOL": "b", "STRUCT": "st" }
}]
}
}
- Severity:
"off", "error", "warning", "info" or "hint", optionally with options as [severity, { ... }]. Completion and hover in lint.json list the rules and their options.
files / ignores: Glob patterns relative to the folder that contains .boost/. Libraries are linted unless you ignore them.
variable-prefix-convention: Checks prefixes by scope, form and type; a global ARRAY[..] OF Motor_typ is then named g_astMotors. Only what you configure is checked, constants never. The Quick Fix renames the variable and all its usages.
Migrating from st.boolPrefix: The setting has been removed. Use "variable-prefix-convention": ["warning", { "type": { "BOOL": "b" } }] instead.
Features coming soon
- Further validation: More validation rules for structured text.
Known Issues
- Changes in dictionary folder structure are not detected (need to reopen the workspace)
- Initialization of complex structures in typ or var files are not fully supported
AVM Engineering AG
www.avm.swiss
Thank you for using BooST! 🚀