fix: handle quoted type names in diagnostics
- Add pattern matching for quoted type names like "MyUDT" - Handle quoted types in ARRAY ... OF declarations - Skip empty base_type to avoid spurious warnings
This commit is contained in:
+4
-3
@@ -144,12 +144,13 @@ function M.validate_diagnostics(content, workspace_types, root_dir)
|
||||
type_part = type_part:gsub("%s*$", "")
|
||||
type_part = type_part:gsub("^%s+", "")
|
||||
|
||||
local base_type = type_part:match("^([%w_]+)")
|
||||
-- Handle quoted type names like "MyUDT"
|
||||
local base_type = type_part:match('^"([^"]+)"') or type_part:match("^([%w_]+)")
|
||||
if type_part:match("%s+OF%s+") then
|
||||
base_type = type_part:match(".*%s+OF%s+([%w_]+)")
|
||||
base_type = type_part:match('.*%s+OF%s+"([^"]+)"') or type_part:match(".*%s+OF%s+([%w_]+)")
|
||||
end
|
||||
local upper_type = base_type and base_type:upper() or nil
|
||||
if base_type and not all_types[base_type] and
|
||||
if base_type and base_type ~= "" and not all_types[base_type] and
|
||||
upper_type ~= "BOOL" and upper_type ~= "INT" and upper_type ~= "DINT" and
|
||||
upper_type ~= "REAL" and upper_type ~= "LREAL" and upper_type ~= "BYTE" and
|
||||
upper_type ~= "WORD" and upper_type ~= "DWORD" and upper_type ~= "LWORD" and
|
||||
|
||||
Reference in New Issue
Block a user