From a4893ab5614646a986d4d970e4359265270f4527 Mon Sep 17 00:00:00 2001 From: Taras Martyniuk Date: Thu, 29 Aug 2024 07:51:08 +0300 Subject: [PATCH] terraform: Add outline queries (#16945) Closes #16944 Added outline schema for terraform/HCL Release Notes: - N/A ![SCR-20240827-omjs](https://github.com/user-attachments/assets/48a31863-e848-4a86-97b7-67440d62c93f) --- .../terraform/languages/hcl/outline.scm | 76 +++++++++++++++++++ .../terraform/languages/terraform/outline.scm | 76 +++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 extensions/terraform/languages/hcl/outline.scm create mode 100644 extensions/terraform/languages/terraform/outline.scm diff --git a/extensions/terraform/languages/hcl/outline.scm b/extensions/terraform/languages/hcl/outline.scm new file mode 100644 index 0000000000..b50e239afc --- /dev/null +++ b/extensions/terraform/languages/hcl/outline.scm @@ -0,0 +1,76 @@ +; HCL Outline Scheme +; Comments +(comment) @annotation + +; Block with and without string_lit +; Example: +; terraform { ... } +; module "vpc" { ... } +; resource "resource" "name" { ... } +(config_file + (body + (block + (identifier) @context + (string_lit)? @name + (string_lit)? @name + ) @item + ) +) + +; Inside block with identifier +(config_file + (body + (block + (identifier) + (body + (attribute + (identifier) @context + ) @item + ) + ) + ) +) + +; Inside block with identifier and string_lit +(config_file + (body + (block + (identifier) + (body + (block + (identifier) @context + (string_lit)? @name + ) @item + ) + ) + ) +) + +; Root Attribute block +; Example: +; inputs = { ... } +(config_file + (body + (attribute + (identifier) @context + ) @item + ) +) + +; Inside Root Attribute block +(config_file + (body + (attribute + (identifier) + (expression + (collection_value + (object + (object_elem + key: (expression (variable_expr (identifier) @context)) + ) @item + ) + ) + ) + ) + ) +) diff --git a/extensions/terraform/languages/terraform/outline.scm b/extensions/terraform/languages/terraform/outline.scm new file mode 100644 index 0000000000..b50e239afc --- /dev/null +++ b/extensions/terraform/languages/terraform/outline.scm @@ -0,0 +1,76 @@ +; HCL Outline Scheme +; Comments +(comment) @annotation + +; Block with and without string_lit +; Example: +; terraform { ... } +; module "vpc" { ... } +; resource "resource" "name" { ... } +(config_file + (body + (block + (identifier) @context + (string_lit)? @name + (string_lit)? @name + ) @item + ) +) + +; Inside block with identifier +(config_file + (body + (block + (identifier) + (body + (attribute + (identifier) @context + ) @item + ) + ) + ) +) + +; Inside block with identifier and string_lit +(config_file + (body + (block + (identifier) + (body + (block + (identifier) @context + (string_lit)? @name + ) @item + ) + ) + ) +) + +; Root Attribute block +; Example: +; inputs = { ... } +(config_file + (body + (attribute + (identifier) @context + ) @item + ) +) + +; Inside Root Attribute block +(config_file + (body + (attribute + (identifier) + (expression + (collection_value + (object + (object_elem + key: (expression (variable_expr (identifier) @context)) + ) @item + ) + ) + ) + ) + ) +)