bmc-tpl-code-all-around/README.md

188 lines
15 KiB
Markdown
Raw Normal View History

English Description first - after that comes the German Version.
Translation:
Englische beschreibung zuerst, danach kommt die Deutsche
2026-10-07 21:34:05 +00:00
---
# BMC TPL Code All-Around
2026-10-07 21:34:05 +00:00
**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.
2026-10-07 21:34:05 +00:00
---
2026-10-07 21:34:05 +00:00
## ✨ Features
2026-10-07 21:34:05 +00:00
### 🤖 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 `enumeration` blocks or multi-line statements). Warns strictly with an error if `=` is used instead of `:=` for variable assignments (outside of legitimate `if`/`where` comparisons).
* **Block & Bracket Tracking:** Detects unclosed blocks (like missing `end body;` or `end pattern;`) and finds unclosed parentheses `(` or brackets `[`.
2026-10-18 01:35:39 +00:00
* **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 initial `log.debug` statement exists in the `body`.
* **Indentation Checking (New):** 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.
* **Version Checking:** Compares the TPL version declared in the module with the target version defined in your settings and warns about outdated scripts.
2026-10-07 21:34:05 +00:00
2026-10-18 01:35:39 +00:00
### ⚙️ Configurable Plugin Settings & Compliance
Personalize the plugin directly via the VS Code user interface (File > Preferences > Settings > Extensions > BMC TPL Settings):
2026-10-18 01:35:39 +00:00
* **Metadata Compliance (New):** Define exact compliance rules for your workspace. Choose which metadata fields are mandatory and configure the `tree_path` strictly (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., `23` for 1.23) you are developing for.
* **Live Reload:** Changes to settings take effect immediately, no editor restart required.
2026-10-07 21:34:05 +00:00
### 🎨 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.
2026-10-07 21:34:05 +00:00
### 💡 IntelliSense & Autocomplete (Cross-File)
Saves an extreme amount of coding time through massive context awareness:
* **Full BMC Standard Library:** Seamless integration of all built-in functions (e.g., `discovery`, `number`, `text`, `model`). Supports parameter overloads (e.g., `number.toText` optionally 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 type `my_helper.`, it automatically suggests all available `define` methods.
* **Local Namespaces:** Detects `definitions` blocks in the same file and suggests their methods.
* **Variable Tracking:** Learns all variables you have defined with `:=` and suggests them to you later.
2026-10-07 21:34:05 +00:00
### 🔍 Hover Documentation (Tooltips)
When you hover over a method name, a pattern, or a table:
2026-10-18 01:35:39 +00:00
* **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 under `define` or `pattern` declarations and renders them as clean Markdown tooltips (even cross-project!).
### ⚡ Quick Fixes (Code Actions / Lightbulb)
Offers immediate repair options with a single click:
2026-10-18 01:35:39 +00:00
* **"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 the `body` block.
* **"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 |
| :--- | :--- |
2026-10-18 01:35:39 +00:00
| `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;`). |
2026-10-18 01:35:39 +00:00
| `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
1. Activate the plugin. (Download the latest from the releases and simply drag the `.vsix` file into the Visual Studio Code add-ons).
2. Open a TPL file in your project and let the analysis run.
3. The linter starts automatically with every keystroke.
4. **Formatting:** Right-click -> *Format Document* (or `Shift + Alt + F`).
5. **Autocomplete:** Triggers automatically while typing, especially after a dot (`.`) during module calls.
6. **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 legitimen `if`/`where` Vergleichen).
* **Block- & Klammer-Tracking:** Erkennt nicht geschlossene Blöcke (wie fehlende `end body;` oder `end pattern;`) und findet ungeschlossene runde `(` oder eckige `[` Klammern.
2026-10-18 01:35:39 +00:00
* **Pflichtfeld-Validierung:** Prüft basierend auf deinen dynamischen Compliance-Settings, ob auf Modul-Ebene zwingend benötigte Metadaten (`origin`, `author`, `tree_path` etc.) vorhanden sind und ob im `body` ein initiales `log.debug` Statement steht.
* **Einrückungs-Prüfung (Neu):** Ein neuer 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.
* **Versions-Prüfung:** Gleicht die im Modul deklarierte TPL-Version mit der in deinen Settings definierten Version ab und warnt vor veralteten Skripten.
2026-10-18 01:35:39 +00:00
### ⚙️ Konfigurierbare Plugin-Einstellungen & Compliance
Personalisiere das Plugin direkt über die VS Code Benutzeroberfläche (File > Preferences > Settings > Extensions > BMC TPL Einstellungen):
2026-10-18 01:35:39 +00:00
* **Metadaten-Compliance (Neu):** Definiere exakte Regeln für deinen Workspace. Wähle, welche Felder Pflicht sind und konfiguriere den `tree_path` strikt (z.B. Mindest-Ebenen und feste Basis-Nodes wie `['MeineFirma', 'IT']`).
* **Standard Metadaten:** Hinterlege deine eigenen Werte für `Author`, `Publisher`, `Origin` etc. Diese werden beim Generieren neuer Module automatisch eingesetzt.
* **TPL Zielversion:** Definiere die TPL-Version (z.B. `23` fü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`, `table` etc.) 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.
### 💡 IntelliSense & Autovervollständigung (Cross-File)
Spart extrem viel Zeit beim Coden durch massives Kontext-Wissen:
* **Volle BMC Standard-Bibliothek:** Nahtlose Integration aller Built-In Funktionen (z.B. `discovery`, `number`, `text`, `model`). Unterstützt Parameter-Überladungen (z.B. `number.toText` wahlweise 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 du `my_helper.`, werden dir automatisch alle verfügbaren `define`-Methoden vorgeschlagen.
2026-10-18 01:35:39 +00:00
* **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 unter `define` oder `pattern` Deklarationen stehen, und rendert sie als saubere Markdown-Tooltips (auch projektübergreifend!).
### ⚡ Quick Fixes (Code Actions / Glühbirne)
Bietet sofortige Reparaturoptionen mit einem Klick:
2026-10-18 01:35:39 +00:00
* **"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 des `body`-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 |
| :--- | :--- |
2026-10-18 01:35:39 +00:00
| `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;`). |
2026-10-18 01:35:39 +00:00
| `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
1. Das Plugin aktivieren. (Von den Releases das neueste herunterladen und einfach die `.vsix` Datei in die Add-ons von Visual Studio Code ziehen).
2. In einem Projekt mit TPL Dateien eine davon öffnen und die Analyse durchlaufen lassen.
3. Der Linter startet automatisch bei jedem Tastendruck.
4. **Formatieren:** Rechtsklick -> *Dokument formatieren* (oder `Shift + Alt + F`).
5. **Autovervollständigung:** Triggert automatisch beim Tippen, speziell nach einem Punkt (`.`) bei Modul-Aufrufen.
6. **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.