feat: remove unassigned output params in formatter + SCL006 diagnostic

- Formatter now strips unassigned output params (e.g. Q =>, ET =>)
  from FB/FC calls during formatting.
- Diagnostics now produce SCL006 warning for unassigned output params.
- Also converted src/ symlinks for diagnostics.lua and formatter.lua
  in mason package so all three files stay in sync.
This commit is contained in:
2026-07-22 17:43:18 +02:00
parent 73735192bd
commit 5205819201
2 changed files with 20 additions and 0 deletions
+11
View File
@@ -254,6 +254,17 @@ 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 =>")
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 output parameter: %s =>", unassigned),
code = "SCL006",
source = "tia_lsp",
})
end
for assignment in line:gmatch("#[%w_]+%s*:=") do
local var_name = assignment:match("#([%w_]+)")
if var_name and in_var_section then
+9
View File
@@ -261,6 +261,15 @@ function M.format_document(content, options)
table.insert(params, last_param)
end
-- Remove unassigned output parameters (e.g. "Q =>", "ET =>")
local filtered = {}
for _, p in ipairs(params) do
if not p:match("^[%w_]+%s*=>%s*$") then
table.insert(filtered, p)
end
end
params = filtered
if #params == 0 then
return { base_indent .. fb_name .. "();" }
end