feat(lsp): add goto declaration for FB, DB, and UDT types

- Add declaration provider (gD) that finds definitions for:
  - Functions in .scl files
  - Function Blocks (FB) in .scl files
  - Data Blocks (DB) in .scl and .db files
  - User-Defined Types (UDT) in .scl and .udt files
- Implement project root detection for cross-directory searches
- Add duplicate location filtering to prevent multiple results
- Load UDT types from .udt files in plc_json
- Update documentation with goto declaration feature
This commit is contained in:
2026-02-19 18:01:30 +01:00
parent cb0b24d47b
commit 577ffa5213
4 changed files with 297 additions and 9 deletions
+15
View File
@@ -198,6 +198,21 @@ function M.load_types_from_workspace(root_dir)
end
end
-- Also scan for .udt files
local udt_files = scan_files_recursive(root_dir, "*.udt")
for _, filepath in ipairs(udt_files) do
local content = run_command("cat " .. filepath:gsub(" ", "\\ "))
if content then
local udt_types = parse_scl_type_file(content)
for name, typ in pairs(udt_types) do
typ.source = "udt_file"
if not types[name] then
types[name] = typ
end
end
end
end
return types
end