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()
This commit is contained in:
2026-07-22 17:48:31 +02:00
parent 5205819201
commit cce4059b7e
2 changed files with 12 additions and 3 deletions
+10 -1
View File
@@ -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),
+2 -2
View File
@@ -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