This commit is contained in:
kuro 2026-10-18 03:07:29 +02:00
commit 00bdc8744d
1 changed files with 99 additions and 1 deletions

100
README.md
View File

@ -1,3 +1,101 @@
English Description first - after that comes the German Version.
Translation:
Englische beschreibung zuerst, danach kommt die Deutsche
---
# 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 `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 `[`.
* **Mandatory Field Validation:** Checks if mandatory module-level metadata (`origin`, `author`, `products`, `publishers`, `tree_path`) are present and if an initial `log.debug` statement exists in the `body`.
* **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
Personalize the plugin directly via the VS Code user interface (File > Preferences > Settings > Extensions > BMC TPL Settings):
* **Default Metadata:** Store your own values for `Author`, `Publisher`, `Origin`, and `Tree Path`. 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.
### 🎨 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.
### 💡 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.
### 🔍 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 (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:
* **"Insert missing module metadata":** Instantly generates all 5 mandatory fields in the module metadata block.
* **"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 |
| :--- | :--- |
| `tpl_skeleton` | **God-Snippet**: Generates a completely fresh TPL module. Automatically uses your configured settings for metadata and version. |
| `pattern` / `syncmapping` | Builds an empty pattern/syncmapping block including DocString and end-tag. |
| `define` | Generates a method definition (`define name(params) ... end define;`). |
| `metadata`, `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).**
@ -32,7 +130,7 @@ Schluss mit kaputten Einrückungen! Der Formatter bringt deinen Code in Bestform
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.
* **Lokale Namespaces:** Erkennt `definitions`-Blöcke in der gleichen Datei und schlägt deren Methoden vor.
* **Lokale Namespaces:** Erkennt `definitions`-Blöcke in class 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)