From bb860106c7d450aa8d00482f3b107cb50d428d2b Mon Sep 17 00:00:00 2001 From: kuro Date: Thu, 15 Oct 2026 20:43:14 +0000 Subject: [PATCH] Add Snippets_en --- Snippets_en.md | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Snippets_en.md diff --git a/Snippets_en.md b/Snippets_en.md new file mode 100644 index 0000000..86c90fc --- /dev/null +++ b/Snippets_en.md @@ -0,0 +1,55 @@ +# 🚀 Snippets & Quick Fixes + +The **BMC TPL Code All around** extension massively reduces your typing effort. With intelligent code templates (Snippets) and automatic error resolutions (Quick Fixes), you write TPL code not only faster but also error-free. + +--- + +## 📝 Smart Snippets (Code Templates) + +Snippets are short abbreviations that turn into complete code blocks when typing (or by pressing `Ctrl + Space`). +*Tip:* After inserting a snippet, you can easily jump through the placeholders (like variable names or conditions) using the `Tab` key! + +### The God-Snippet +| Keyword | Description | +| :--- | :--- | +| `tpl_skeleton` | Generates a completely fresh `.tpl` file including module definition, mandatory metadata, pattern, triggers, and log statements. **Special feature:** Automatically pulls your name, the publisher, and the TPL version from your VS Code settings! | + +### Control Structures (New!) +No more forgotten `then`, `do`, or `end` blocks. Just type the keyword and press `Tab`: + +| Keyword | Generated Code | +| :--- | :--- | +| `if` | Builds `if then ... end if;` and places the cursor inside the condition. | +| `elif` | Builds `elif then ...` for seamless if-chains. | +| `else` | Builds the `else ...` block. | +| `for` | Builds `for in do ... end for;`. | +| `while` | Builds `while do ... end while;`. | + +### TPL Structures & Blocks +| Keyword | Description | +| :--- | :--- | +| `pattern` | Builds an empty pattern block including a DocString (`"""`) and `end pattern;`. | +| `syncmapping` | Builds an empty syncmapping block including a DocString. | +| `define` | Generates a method definition (`define name(params) ... end define;`). | +| `table` | Creates a table including the mandatory `default -> "unknown";` fallback. | +| `metadata`, `body`, ... | Builds the respective TPL block (`metadata ... end metadata;`) and places the cursor in the middle. | + +--- + +## ⚡ Quick Fixes (Code Actions) + +When the linter finds an error or a warning, a small **lightbulb** often appears at the beginning of the line. You can also simply click on the marked line and press `Ctrl + .` (Windows/Linux) or `Cmd + .` (Mac) to have the problem fixed automatically. + +Currently, the extension supports the following automatic repairs: + +### 1. "Generate missing module metadata" +- **Trigger:** You have a `metadata` block, but mandatory fields are missing (like `origin`, `author`, `products`, `publishers`, or `tree_path`). +- **Action:** The plugin immediately generates the missing lines with dummy values inside the block, making the code valid again. + +### 2. "Insert log statement" +- **Trigger:** The initially required `log.debug` statement with the pattern name is missing in the `body` of a pattern. +- **Action:** Inserts the missing `log.debug("Start pattern ");` right as the first line in the `body` block. + +### 3. "Tabs to Spaces" +- **Trigger:** The linter finds tab characters (`\t`) in the code. (Spaces are best practice in BMC TPL). +- **Action:** Instantly replaces all illegal tabs in the flagged line with 4 clean spaces each. \ No newline at end of file