feat: comprehensive query files for all block types and VAR sections (Phase 3)

Update all 5 tree-sitter query files to cover the full grammar:

highlights.scm:
- Add highlights for new literals (binary, octal, date, bool, typed_int,
  wstring, char)
- Add highlights for block names (organization_block, function_block,
  function, data_block, type_definition)
- Add highlights for return_statement, goto_statement, title_statement
- Add highlights for bit_access, method_callee
- Add compound assignment operators (+=, -=, *=, /=, etc.)

indents.scm:
- Add function, type_definition, data_block to @indent.begin
- Add all var_*_declaration variants to @indent.begin
- Add struct_type to @indent.begin
- Add END_FUNCTION, END_TYPE, END_DATA_BLOCK, END_STRUCT to @indent.end

folds.scm:
- Add function, type_definition, data_block to @fold
- Add all var_*_declaration variants to @fold
- Add struct_type to @fold

locals.scm:
- Add function, type_definition, data_block as @local.scope
- Add all var_*_declaration variants as @local.scope
- Add struct_type as @local.scope
- Add block name definitions (@definition.function, @definition.class,
  @definition.type)
- Narrow @reference to prefixed_identifier only (reduces noise)

tags.scm:
- Add function, data_block, type_definition tags
- Add FB call references
- Add region_statement as @definition.module
This commit is contained in:
2026-07-18 19:20:33 +02:00
parent aebffc34e7
commit 03548dab7d
5 changed files with 148 additions and 21 deletions
+9
View File
@@ -3,12 +3,21 @@
[
(organization_block)
(function_block)
(function)
(type_definition)
(data_block)
(var_declaration)
(var_temp_declaration)
(var_constant_declaration)
(var_retain_declaration)
(var_non_retain_declaration)
(var_db_specific_declaration)
(if_statement)
(case_statement)
(for_statement)
(while_statement)
(repeat_statement)
(region_statement)
(struct_type)
(block_comment)
] @fold
+58 -11
View File
@@ -1,66 +1,99 @@
; SCL highlights
; Comments
(line_comment) @comment
(block_comment) @comment
(c_style_comment) @comment
; Literals
(number) @number
(hex_number) @number
(string) @string
(binary_number) @number
(octal_number) @number
(time_value) @number
(date_literal) @number
(bool_literal) @constant.builtin
(typed_int_literal) @number
(wstring_literal) @string
(char_literal) @character
(string) @string
; Prefix
(prefix) @punctuation.special
; Variables and identifiers
(identifier) @variable
; FB instance calls - highlight instance name as type
; FB instance calls
(fb_call
instance: (prefixed_identifier
(identifier) @type))
(fb_call
instance: (identifier) @type)
; FB parameter names (IN :=, PT :=, etc.)
; FB parameter names
(fb_parameter
name: (identifier) @property)
; Function call names
(function_call
(identifier) @function)
(function_call
(string) @function)
; Method call names
(method_callee
(identifier) @function)
; Variable declarations
(var_item
name: (identifier) @variable)
; Type references in declarations
; Type references
(type
(identifier) @type)
(type_builtin) @type.builtin
; Keywords and operators
(keyword) @keyword
(constant) @constant.builtin
(operator) @operator
(assignment) @operator
(binary_expression) @operator
(unary_expression) @operator
; Block names
(organization_block
name: (string) @type)
(function_block
name: (string) @type)
(function
name: (string) @function)
(data_block
name: (string) @type)
(type_definition
name: (string) @type)
; Access
(field_access
"."
(identifier) @property)
(array_access) @property
(bit_access) @property
; Attributes
(attribute_list) @attribute
(attribute) @attribute
(attribute_value) @string
(var_item) @property
; Statements
(assignment) @operator
(binary_expression) @operator
(unary_expression) @operator
(chained_assignment) @operator
; Function/FB calls
(function_call) @function.call
(fb_call) @function.call
; Control flow
(if_statement) @conditional
(elsif_clause) @conditional
(else_clause) @conditional
@@ -71,6 +104,13 @@
(while_statement) @repeat
(repeat_statement) @repeat
(return_statement) @keyword
(goto_statement) @keyword
; Title
(title_statement) @comment
; Punctuation
";" @punctuation.delimiter
":" @punctuation.delimiter
"," @punctuation.delimiter
@@ -80,15 +120,22 @@
"]" @punctuation.bracket
"." @punctuation.delimiter
; Operators
":=" @operator
"=>" @operator
"+=" @operator
"-=" @operator
"*=" @operator
"/=" @operator
"&=" @operator
"|=" @operator
"^=" @operator
"=" @operator
"<>" @operator
"<" @operator
">" @operator
"<=" @operator
">=" @operator
"+" @operator
"-" @operator
"*" @operator
+26 -2
View File
@@ -1,10 +1,26 @@
; Indentation rules for SCL
; Indent after block keywords
; Indent after block definitions
[
(organization_block)
(function_block)
(function)
(type_definition)
(data_block)
] @indent.begin
; Indent after VAR sections
[
(var_declaration)
(var_temp_declaration)
(var_constant_declaration)
(var_retain_declaration)
(var_non_retain_declaration)
(var_db_specific_declaration)
] @indent.begin
; Indent after control structures
[
(if_statement)
(case_statement)
(for_statement)
@@ -13,12 +29,16 @@
(region_statement)
] @indent.begin
; Indent after THEN, DO, etc.
; Indent after STRUCT in UDTs and inline structs
(struct_type) @indent.begin
; Indent after THEN, DO, ELSE, ELSIF, BEGIN
[
"THEN"
"DO"
"ELSE"
"ELSIF"
(keyword) @indent.branch
] @indent.branch
; Outdent at end keywords
@@ -30,8 +50,12 @@
"END_WHILE"
"END_REPEAT"
"END_REGION"
"END_STRUCT"
"END_ORGANIZATION_BLOCK"
"END_FUNCTION_BLOCK"
"END_FUNCTION"
"END_TYPE"
"END_DATA_BLOCK"
] @indent.end
; Outdent for ELSE and ELSIF
+30 -6
View File
@@ -1,15 +1,39 @@
; Local variable scoping for SCL - matches grammar.js structure
; Local variable scoping for SCL
; Variable declarations define local variables
(var_item
name: (identifier) @definition.var)
; Variable sections create scopes
(var_declaration) @local.scope
; Blocks create scopes
(organization_block) @local.scope
(function_block) @local.scope
(function) @local.scope
(type_definition) @local.scope
(data_block) @local.scope
; Identifiers are references
(identifier) @reference
; VAR sections create scopes
(var_declaration) @local.scope
(var_temp_declaration) @local.scope
(var_constant_declaration) @local.scope
(var_retain_declaration) @local.scope
(var_non_retain_declaration) @local.scope
(var_db_specific_declaration) @local.scope
; Struct types create scopes
(struct_type) @local.scope
; Block names are definitions
(organization_block
name: (string) @definition.function)
(function_block
name: (string) @definition.function)
(function
name: (string) @definition.function)
(data_block
name: (string) @definition.class)
(type_definition
name: (string) @definition.type)
; References
(prefixed_identifier
(identifier) @reference)
+24 -1
View File
@@ -1,4 +1,4 @@
; Tag queries for SCL - matches grammar.js structure
; Tag queries for SCL - symbol navigation
; Organization blocks
(organization_block
@@ -8,6 +8,18 @@
(function_block
name: (string) @name) @definition.function
; Functions
(function
name: (string) @name) @definition.function
; Data blocks
(data_block
name: (string) @name) @definition.class
; Type definitions (UDTs)
(type_definition
name: (string) @name) @definition.type
; Variable definitions within blocks
(var_item
name: (identifier) @name
@@ -25,3 +37,14 @@
(function_call
(string) @name) @reference.call
; FB calls (references)
(fb_call
instance: (identifier) @name) @reference.call
(fb_call
instance: (prefixed_identifier
(identifier) @name)) @reference.call
; Region statements
(region_statement) @definition.module