From cce4059b7eb0ac1d1721d325eeab260c0ae66df6 Mon Sep 17 00:00:00 2001 From: Lazar Bulovan Date: Wed, 22 Jul 2026 17:48:31 +0200 Subject: [PATCH] fix: also warn on unassigned input params + collapse all-unassigned calls - SCL006 now fires for both unassigned inputs (IN := <-,) and outputs (Q =>) - Formatter removes both IN := and Q => when no value follows - When ALL params are unassigned, the call collapses to name() --- src/diagnostics.lua | 11 ++++++++++- src/formatter.lua | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/diagnostics.lua b/src/diagnostics.lua index ed86057..17c98d6 100644 --- a/src/diagnostics.lua +++ b/src/diagnostics.lua @@ -254,7 +254,16 @@ function M.validate_diagnostics(content, workspace_types, root_dir) if trimmed:match("^%s*//") or trimmed:match("^%s*%(%*") then -- Skip comments else - -- Check for unassigned output parameters in FB/FC calls (e.g. "Q =>") + -- Check for unassigned parameters in FB/FC calls + for unassigned in line:gmatch("([%w_]+)%s*:=%s*[,%)]") do + table.insert(diagnostics, { + range = range_to_lsp(line_num, line:find(unassigned, 1, true) - 1, line_num, line:find(unassigned, 1, true) + #unassigned), + severity = DiagnosticSeverity.Warning, + message = string.format("Unassigned input parameter: %s :=", unassigned), + code = "SCL006", + source = "tia_lsp", + }) + end for unassigned in line:gmatch("([%w_]+)%s*=>%s*[,%)]") do table.insert(diagnostics, { range = range_to_lsp(line_num, line:find(unassigned, 1, true) - 1, line_num, line:find(unassigned, 1, true) + #unassigned), diff --git a/src/formatter.lua b/src/formatter.lua index 3843873..e45927a 100644 --- a/src/formatter.lua +++ b/src/formatter.lua @@ -261,10 +261,10 @@ function M.format_document(content, options) table.insert(params, last_param) end - -- Remove unassigned output parameters (e.g. "Q =>", "ET =>") + -- Remove unassigned parameters (e.g. "IN :=", "Q =>", "ET =>") local filtered = {} for _, p in ipairs(params) do - if not p:match("^[%w_]+%s*=>%s*$") then + if not p:match("^[%w_]+%s*:=%s*$") and not p:match("^[%w_]+%s*=>%s*$") then table.insert(filtered, p) end end