|
|
||
|---|---|---|
| .gitea/workflows | ||
| .vscode | ||
| src | ||
| syntaxes | ||
| .gitignore | ||
| .vscode-test.mjs | ||
| .vscodeignore | ||
| LICENSE.md | ||
| README.md | ||
| build_release.sh | ||
| esbuild.js | ||
| eslint.config.mjs | ||
| icon.png | ||
| language-configuration.json | ||
| linter_fixes.sh | ||
| package-lock.json | ||
| package.json | ||
| tsconfig.json | ||
README.md
English Description first - after that comes the German Version.
BMC TPL Code All-Around
Linter, Auto-Formatter, IntelliSense, and Hover Documentation for the BMC TPL (Topology Pattern Language).
This Visual Studio Code extension transforms your editor into a fully-fledged development environment for BMC Discovery TPL scripts. It saves you typing, formats code according to strict best practices, prevents syntax errors before deployment, and understands cross-project dependencies.
✨ Features
🤖 Intelligent Linter (Syntax Scanner)
The linter analyzes the code in real-time, remembers states across line breaks, and warns you about typical TPL errors:
- Strict Hierarchy Checking: Monitors the correct order of blocks within patterns and syncmappings (
metadata->overview->constants->triggers->mapping/removal->body). - Smart Assignment Check: Finds missing semicolons (but tolerates them in
enumerationblocks or multi-line statements). Warns strictly with an error if=is used instead of:=for variable assignments (outside of legitimateif/wherecomparisons). - Block & Bracket Tracking: Detects unclosed blocks (like missing
end body;orend pattern;) and finds unclosed parentheses(or brackets[. - Mandatory Field Validation: Checks if mandatory module-level metadata (
origin,author,products,publishers,tree_path) are present based on your dynamic compliance settings, and if an initiallog.debugstatement exists in thebody. - Indentation Checking: Instantly highlights messy indentation (any space count that is not a clean multiple of 4) with a warning, reminding you to use the Auto-Formatter.
- Unbreakable Lexer (New): Built-in state-machine lexer correctly parses complex strings, triple-quotes (
"""), and comments, ensuring accurate parameter counting and avoiding false-positive errors on complex TPL syntax. - Version Checking: Compares the TPL version declared in the module with the target version defined in your settings and warns about outdated scripts.
⚙️ Configurable Plugin Settings & Compliance
Personalize the plugin directly via the VS Code user interface (File > Preferences > Settings > Extensions > BMC TPL Settings):
- Metadata Compliance: Define exact compliance rules for your workspace. Choose which metadata fields are mandatory and configure the
tree_pathstrictly (e.g., minimum depth and forced static base nodes like['MyCompany', 'IT']). - Default Metadata: Store your own values for
Author,Publisher,Origin, etc. These are automatically inserted when generating new modules. - TPL Target Version: Define the default TPL version (e.g.,
23for 1.23) you are developing for. - Live Reload: Changes to settings take effect immediately, no editor restart required.
🎨 Auto-Formatter & Visual Alignment (Shift + Alt + F)
No more broken indentations! The formatter gets your code in top shape:
- VS Code Standard: Strictly enforces 4 spaces per indentation level.
- Dynamic Block Indentation: Automatically detects starting and ending blocks (
if,for,pattern,table, etc.) and adjusts the indentation level. - Bracket Memory (Visual Alignment): The ultimate discipline! The formatter remembers the exact column position of opened arrays
[or function calls(and flawlessly aligns all subsequent lines to this bracket. - Uncompromising Cleanup (New): Automatically strips all non-standard indentation (like 2, 3, or 6 spaces) and replaces it with exact, mathematically calculated 4-space blocks.
💡 IntelliSense & Autocomplete (Cross-File)
Saves an extreme amount of coding time through massive context awareness:
- "Go to Definition" (New): Instantly navigate your codebase!
Ctrl+Click(orF12) on any function call to jump directly to its declaration. Searches locally first and falls back to the RAM-based workspace index for cross-file jumps. - Dynamic Taxonomy Support (New): Full autocomplete support for dynamic BMC scopes. Typing
model.suggests generic<NodeKind>constructors, whilemodel.rel.offers dynamic<Relationship>constructors with ready-to-use snippets. - Full BMC Standard Library: Seamless integration of all built-in functions (e.g.,
discovery,number,text,model). Supports parameter overloads (e.g.,number.toTextoptionally with or without a base) via Tab navigation. - Workspace Scanning: If you import a module (e.g.,
from company.helpers import my_helper), the plugin scans your entire project in the background. If you typemy_helper., it automatically suggests all availabledefinemethods. - Case-Insensitive Resolution (New): All method lookups (both Core and TKU) are completely case-insensitive, meaning
rdbms_functions.xyzworks just as flawlessly asRDBMS_Functions.Xyz. - Local Namespaces: Detects
definitionsblocks in the same file and suggests their methods. - Variable Tracking: Learns all variables you have defined with
:=and suggests them to you later.
🔍 Hover Documentation (Tooltips)
When you hover over a method name, a pattern, or a table:
- Official BMC Docs: Full integration of the original, multi-line BMC documentation for all built-in functions loaded dynamically (no browser needed anymore!).
- DocString Extraction: Reads custom multi-line comments (
"""or''') placed underdefineorpatterndeclarations and renders them as clean Markdown tooltips (even cross-project!).
⚡ Quick Fixes (Code Actions / Lightbulb)
Offers immediate repair options with a single click:
- "Insert missing module metadata": Instantly generates missing mandatory fields in the module metadata block based on your workspace compliance settings.
- "Insert log statement": Adds the missing
log.debug("Start pattern...");right at the beginning of thebodyblock. - "Tabs to Spaces": Instantly replaces all illegal tabs (
\t) in a line with 4 correct spaces each.
🚀 Snippets (Code Templates)
Just type the keyword and press Enter to generate complete, perfectly indented blocks:
| Keyword | Description |
|---|---|
tpl_skeleton |
God-Snippet: Generates a completely fresh TPL module. Automatically uses your configured compliance rules, settings, and dynamic tree paths. |
metadata |
Context-Aware: Knows where your cursor is. Generates a full module block at the top, or a compact pattern block inside a pattern. |
pattern / syncmapping |
Builds an empty pattern/syncmapping block including DocString and end-tag. |
define |
Generates a method definition (define name(params) ... end define;). |
overview, body... |
Builds the respective block and places the cursor right in the middle. |
table |
Creates a table including the default -> "unknown"; fallback. |
if, elif, else |
Builds conditional statements incl. then and end if;, placing the cursor neatly at the condition. |
for, while |
Builds standard loops incl. do and end-tag, letting you iterate directly. |
🛠️ Installation & Usage
- Activate the plugin. (Download the latest from the releases and simply drag the
.vsixfile into the Visual Studio Code add-ons). - Open a TPL file in your project and let the analysis run.
- The linter starts automatically with every keystroke.
- Formatting: Right-click -> Format Document (or
Shift + Alt + F). - Autocomplete: Triggers automatically while typing, especially after a dot (
.) during module calls. - Navigation: Press
Ctrl+ Click (orF12) to jump to function definitions. - Quick Fixes: Click the yellow/red lightbulb at the beginning of the line or press
Ctrl + .(Windows/Linux) /Cmd + .(Mac).
📜 License
This project is licensed under the MIT License.
Copyright (c) 2026 Thomas Wehnert
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
BMC TPL Code All-Around
Linter, Auto-Formatter, IntelliSense und Hover-Dokumentationen für die BMC TPL (Template Language).
Diese Visual Studio Code Erweiterung verwandelt deinen Editor in eine vollwertige Entwicklungsumgebung für BMC Discovery TPL-Skripte. Sie nimmt dir Tipparbeit ab, formatiert Code nach strengen Best Practices, verhindert Syntax-Fehler noch vor dem Deployment und versteht projektübergreifende Abhängigkeiten.
✨ Features
🤖 Intelligenter Linter (Syntax-Scanner)
Der Linter analysiert den Code in Echtzeit, merkt sich Zustände über Zeilenumbrüche hinweg und warnt vor typischen TPL-Fehlern:
- Strikte Hierarchie-Prüfung: Überwacht die korrekte Reihenfolge der Blöcke innerhalb von Patterns und Syncmappings (
metadata->overview->constants->triggers->mapping/removal->body). - Smarter Zuweisungs-Check: Findet fehlende Semikolons (toleriert sie aber in
enumeration-Blöcken oder bei umgebrochenen Code-Zeilen). Warnt streng mit einem Fehler, wenn=anstelle von:=für Variablenzuweisungen genutzt wird (außerhalb von legitimenif/whereVergleichen). - Block- & Klammer-Tracking: Erkennt nicht geschlossene Blöcke (wie fehlende
end body;oderend pattern;) und findet ungeschlossene runde(oder eckige[Klammern. - Pflichtfeld-Validierung: Prüft basierend auf deinen dynamischen Compliance-Settings, ob auf Modul-Ebene zwingend benötigte Metadaten (
origin,author,tree_pathetc.) vorhanden sind und ob imbodyein initialeslog.debugStatement steht. - Einrückungs-Prüfung: Ein Check im Hintergrund markiert unsaubere Einrückungen (alles, was kein sauberes Vielfaches von 4 Leerzeichen ist) sofort mit einer Warnung, um an den Auto-Formatter zu erinnern.
- Unzerstörbarer Lexer (Neu): Ein eingebauter State-Machine-Lexer verarbeitet komplexe Strings, Triple-Quotes (
""") und Kommentare fehlerfrei. Dadurch zählt der Linter Parameter immer korrekt und wirft keine falschen Fehler bei komplexer TPL-Syntax. - Versions-Prüfung: Gleicht die im Modul deklarierte TPL-Version mit der in deinen Settings definierten Version ab und warnt vor veralteten Skripten.
⚙️ Konfigurierbare Plugin-Einstellungen & Compliance
Personalisiere das Plugin direkt über die VS Code Benutzeroberfläche (File > Preferences > Settings > Extensions > BMC TPL Einstellungen):
- Metadaten-Compliance: Definiere exakte Regeln für deinen Workspace. Wähle, welche Felder Pflicht sind und konfiguriere den
tree_pathstrikt (z.B. Mindest-Ebenen und feste Basis-Nodes wie['MeineFirma', 'IT']). - Standard Metadaten: Hinterlege deine eigenen Werte für
Author,Publisher,Originetc. Diese werden beim Generieren neuer Module automatisch eingesetzt. - TPL Zielversion: Definiere die TPL-Version (z.B.
23für 1.23), für die du standardmäßig entwickelst. - Live-Reload: Änderungen an den Einstellungen greifen sofort, ganz ohne Neustart des Editors.
🎨 Auto-Formatter & Visual Alignment (Shift + Alt + F)
Schluss mit kaputten Einrückungen! Der Formatter bringt deinen Code in Bestform:
- VS Code Standard: Erzwingt strikt 4 Leerzeichen pro Einrückungs-Ebene.
- Dynamische Block-Einrückung: Erkennt automatisch startende und endende Blöcke (
if,for,pattern,tableetc.) und passt die Einrückungsebene an. - Klammer-Gedächtnis (Visual Alignment): Die Königsdisziplin! Der Formatter merkt sich die spaltengenaue Position von geöffneten Arrays
[oder Funktionsaufrufen(und richtet alle Folgezeilen makellos an dieser Klammer aus. - Kompromisslose Bereinigung (Neu): Unsaubere Einrückungen (z.B. 2, 3 oder 6 Leerzeichen) werden restlos rasiert und durch exakt berechnete 4-Space-Blöcke ersetzt.
💡 IntelliSense & Autovervollständigung (Cross-File)
Spart extrem viel Zeit beim Coden durch massives Kontext-Wissen:
- "Go to Definition" (Neu): Navigiere sofort durch deine Codebase!
Strg+Klick(oderF12) auf einen Funktionsaufruf springt direkt zur Deklaration. Sucht erst lokal und weicht für dateiübergreifende Aufrufe blitzschnell auf den RAM-Index aus. - Dynamische Taxonomie (Neu): Voller Support für dynamische BMC-Scopes. Das Tippen von
model.schlägt einen generischen<NodeKind>-Konstruktor vor, währendmodel.rel.dynamische<Relationship>-Konstruktoren mit fertigen Snippets anbietet. - Volle BMC Standard-Bibliothek: Nahtlose Integration aller Built-In Funktionen (z.B.
discovery,number,text,model). Unterstützt Parameter-Überladungen (z.B.number.toTextwahlweise mit oder ohne Basis) per Tab-Navigation. - Workspace-Scanning: Importierst du ein Modul (z.B.
from company.helpers import my_helper), durchsucht das Plugin im Hintergrund dein gesamtes Projekt. Tippst dumy_helper., werden dir automatisch alle verfügbarendefine-Methoden vorgeschlagen. - Case-Insensitive Auswertung (Neu): Alle Methoden (Core und TKU) werden nun komplett groß-/kleinschreibungsunabhängig aufgelöst (
rdbms_functions.xyzfunktioniert genauso tadellos wieRDBMS_Functions.Xyz). - Lokale Namespaces: Erkennt
definitions-Blöcke in der gleichen Datei und schlägt deren Methoden vor. - Variablen-Tracking: Lernt alle Variablen, die du mit
:=definiert hast, und schlägt sie dir später vor.
🔍 Hover-Dokumentation (Tooltips)
Wenn du mit der Maus über einem Methodennamen, einem Pattern oder einer Tabelle stehen bleibst:
- Offizielle BMC Doku: Volle Integration der originalen, mehrzeiligen BMC Dokumentationen für alle eingebauten Funktionen (kein Browser mehr nötig!).
- DocString Extraction: Liest eigene Multi-Line-Kommentare (
"""oder''') aus, die unterdefineoderpatternDeklarationen stehen, und rendert sie als saubere Markdown-Tooltips (auch projektübergreifend!).
⚡ Quick Fixes (Code Actions / Glühbirne)
Bietet sofortige Reparaturoptionen mit einem Klick:
- "Fehlende Modul-Metadaten einfügen": Generiert sofort alle fehlenden Pflichtfelder im Modul-Metadata-Block, basierend auf deinen Compliance-Settings.
- "Log-Statement einfügen": Baut das fehlende
log.debug("Start pattern...");direkt am Anfang desbody-Blocks ein. - "Tabs zu Spaces": Ersetzt sofort alle illegalen Tabs (
\t) in einer Zeile durch jeweils 4 korrekte Leerzeichen.
🚀 Snippets (Code-Vorlagen)
Einfach das Keyword tippen und Enter drücken, um komplette, perfekt eingerückte Blöcke zu generieren:
| Keyword | Beschreibung |
|---|---|
tpl_skeleton |
God-Snippet: Generiert ein komplett frisches TPL Modul. Nutzt automatisch deine hinterlegten Settings, dynamischen Tree-Paths und Compliance-Regeln. |
metadata |
Kontext-sensitiv: Weiß genau, wo dein Cursor steht. Generiert einen großen Modul-Block ganz oben oder einen kompakten Pattern-Block innerhalb eines Patterns. |
pattern / syncmapping |
Baut einen leeren Pattern/Syncmapping-Block inklusive DocString und End-Tag. |
define |
Generiert eine Methodendefinition (define name(params) ... end define;). |
overview, body... |
Baut den jeweiligen Block auf und platziert den Cursor in der Mitte. |
table |
Erstellt eine Tabelle inklusive des default -> "unknown"; Fallbacks. |
if, elif, else |
Baut bedingte Abfragen inkl. then und end if; und platziert den Cursor sauber bei der Bedingung. |
for, while |
Baut Standard-Schleifen inkl. do und End-Tag und lässt dich direkt iterieren. |
🛠️ Installation & Nutzung
- Das Plugin aktivieren. (Von den Releases das neueste herunterladen und einfach die
.vsixDatei in die Add-ons von Visual Studio Code ziehen). - In einem Projekt mit TPL Dateien eine davon öffnen und die Analyse durchlaufen lassen.
- Der Linter startet automatisch bei jedem Tastendruck.
- Formatieren: Rechtsklick -> Dokument formatieren (oder
Shift + Alt + F). - Autovervollständigung: Triggert automatisch beim Tippen, speziell nach einem Punkt (
.) bei Modul-Aufrufen. - Navigieren: Mit
Strg+ Klick (oderF12) direkt zu Funktionsdefinitionen springen. - Quick Fixes: Auf die gelbe/rote Glühbirne am Zeilenanfang klicken oder
Ctrl + .(Windows/Linux) /Cmd + .(Mac) drücken.
📜 Lizenz
Dieses Projekt ist unter der MIT License lizenziert.
Copyright (c) 2026 Thomas Wehnert
Jedem, der eine Kopie dieser Software erhält, wird hiermit kostenlos die Erlaubnis erteilt, ohne Einschränkung mit der Software zu handeln, einschließlich und ohne Einschränkung der Rechte zur Nutzung, zum Kopieren, Ändern, Zusammenführen, Veröffentlichen, Verteilen, Unterlizenzieren und/oder Verkaufen von Kopien der Software, sofern der obige Urheberrechtshinweis und dieser Genehmigungshinweis in allen Kopien oder wesentlichen Teilen der Software enthalten sind. Die Software wird "ohne Mängelgewähr" (as is) zur Verfügung gestellt.