summaryrefslogtreecommitdiff
path: root/script/vm/global.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-08-16 17:04:25 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-08-16 17:04:25 +0800
commitbe5b77b7956970647d4d12d0e83ccf9bb410565b (patch)
treed5a1e94e71b309524da9f6a4a9fa23c5e2f077b4 /script/vm/global.lua
parentb53c18f1fe69c07c65378892ea42346c593f5023 (diff)
downloadlua-language-server-be5b77b7956970647d4d12d0e83ccf9bb410565b.zip
supports `---@enum (key)`
Diffstat (limited to 'script/vm/global.lua')
-rw-r--r--script/vm/global.lua38
1 files changed, 29 insertions, 9 deletions
diff --git a/script/vm/global.lua b/script/vm/global.lua
index 4e2d0617..e830f6d8 100644
--- a/script/vm/global.lua
+++ b/script/vm/global.lua
@@ -372,16 +372,36 @@ local compilerGlobalSwitch = util.switch()
return
end
source._enums = {}
- for _, field in ipairs(tbl) do
- if field.type == 'tablefield' then
- source._enums[#source._enums+1] = field
- local subType = vm.declareGlobal('type', name .. '.' .. field.field[1], uri)
- subType:addSet(uri, field)
- elseif field.type == 'tableindex' then
- source._enums[#source._enums+1] = field
- if field.index.type == 'string' then
- local subType = vm.declareGlobal('type', name .. '.' .. field.index[1], uri)
+ if vm.docHasAttr(source, 'key') then
+ for _, field in ipairs(tbl) do
+ if field.type == 'tablefield' then
+ source._enums[#source._enums+1] = {
+ type = 'doc.type.string',
+ start = field.field.start,
+ finish = field.field.finish,
+ [1] = field.field[1],
+ }
+ elseif field.type == 'tableindex' then
+ source._enums[#source._enums+1] = {
+ type = 'doc.type.string',
+ start = field.index.start,
+ finish = field.index.finish,
+ [1] = field.index[1],
+ }
+ end
+ end
+ else
+ for _, field in ipairs(tbl) do
+ if field.type == 'tablefield' then
+ source._enums[#source._enums+1] = field
+ local subType = vm.declareGlobal('type', name .. '.' .. field.field[1], uri)
subType:addSet(uri, field)
+ elseif field.type == 'tableindex' then
+ source._enums[#source._enums+1] = field
+ if field.index.type == 'string' then
+ local subType = vm.declareGlobal('type', name .. '.' .. field.index[1], uri)
+ subType:addSet(uri, field)
+ end
end
end
end