diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-11-03 17:10:37 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-11-03 17:10:37 +0800 |
commit | e9a1f9bec74809b3102e58109ab368533f4bb308 (patch) | |
tree | 193a16347bc4a3a099ff34ac88d91815a036baa7 /script-beta | |
parent | 0a1039e8e1c56c8c4260654be66394fd9052a094 (diff) | |
download | lua-language-server-e9a1f9bec74809b3102e58109ab368533f4bb308.zip |
穿透 alias
Diffstat (limited to 'script-beta')
-rw-r--r-- | script-beta/core/completion.lua | 20 | ||||
-rw-r--r-- | script-beta/vm/getDocs.lua | 22 |
2 files changed, 42 insertions, 0 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua index 8612bd62..ff92cb95 100644 --- a/script-beta/core/completion.lua +++ b/script-beta/core/completion.lua @@ -897,6 +897,26 @@ local function getCallEnums(source, index) end return enums end + if source.type == 'function' and source.bindDocs then + local arg = source.args and source.args[index] + if not arg then + return + end + for _, doc in ipairs(source.bindDocs) do + if doc.type == 'doc.param' + and doc.param[1] == arg[1] then + local enums = {} + for _, enum in ipairs(vm.getDocEnums(doc.extends)) do + enums[#enums+1] = { + label = enum[1], + description = nil, + kind = define.CompletionItemKind.EnumMember, + } + end + return enums + end + end + end end local function tryLabelInString(label, arg) diff --git a/script-beta/vm/getDocs.lua b/script-beta/vm/getDocs.lua index a89247b1..2763addb 100644 --- a/script-beta/vm/getDocs.lua +++ b/script-beta/vm/getDocs.lua @@ -77,6 +77,28 @@ local function getDocTypes(name) return results end +function vm.getDocEnums(doc, mark, results) + mark = mark or {} + if mark[doc] then + return nil + end + mark[doc] = true + results = results or {} + for _, enum in ipairs(doc.enums) do + results[#results+1] = enum + end + for _, unit in ipairs(doc.types) do + if unit.type == 'doc.type.name' then + for _, other in ipairs(vm.getDocTypes(unit[1])) do + if other.type == 'doc.alias.name' then + vm.getDocEnums(other.parent.extends, mark, results) + end + end + end + end + return results +end + function vm.getDocTypes(name) local cache = vm.getCache('getDocTypes')[name] if cache ~= nil then |