From d24e83a1a70922aa12875774ea0d33e2e1b3aa46 Mon Sep 17 00:00:00 2001 From: Lazar Bulovan Date: Thu, 23 Jul 2026 13:55:07 +0200 Subject: [PATCH] fix: register FBs with only VAR/TEMP as types + add SCLRescanWorkspaceTypes command --- src/main.lua | 13 +++++++++++++ src/plc_json.lua | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main.lua b/src/main.lua index d894d5d..6312d81 100644 --- a/src/main.lua +++ b/src/main.lua @@ -71,6 +71,9 @@ local capabilities = { workspaceSymbolProvider = true, documentFormattingProvider = true, documentRangeFormattingProvider = false, + executeCommandProvider = { + commands = { "SCLRescanWorkspaceTypes" }, + }, } local function uri_to_path(uri) @@ -1812,6 +1815,16 @@ function handlers.textDocument_formatting(params) return formatter.format_document(doc.content, format_options) end +function handlers.workspace_executeCommand(params) + if params.command ~= "SCLRescanWorkspaceTypes" then + return nil + end + + plc_json.clear_cache() + + return {} +end + local function handle_message(message) if message.method == "$/cancelRequest" then return nil diff --git a/src/plc_json.lua b/src/plc_json.lua index 0e0ece9..27122cf 100644 --- a/src/plc_json.lua +++ b/src/plc_json.lua @@ -127,7 +127,7 @@ local function parse_scl_type_file(content) fb_inouts = {} current_fb_section = nil elseif in_fb and trimmed:match("^END_FUNCTION_BLOCK") then - if fb_name and (#fb_inputs > 0 or #fb_outputs > 0 or #fb_inouts > 0) then + if fb_name then types[fb_name] = { name = fb_name, kind = "function_block",