diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-11-28 20:05:10 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-11-28 20:05:10 +0800 |
commit | 1038520109da932c2e648da6ffa9bf25d36944b8 (patch) | |
tree | 697c69fce6f50825f8c13d9cdbad8b8f5726c6e3 /script-beta/core/hover/class.lua | |
parent | 37bc70744d6642b964ba513bab99b8f0091483f7 (diff) | |
download | lua-language-server-1038520109da932c2e648da6ffa9bf25d36944b8.zip |
支持class
Diffstat (limited to 'script-beta/core/hover/class.lua')
-rw-r--r-- | script-beta/core/hover/class.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/script-beta/core/hover/class.lua b/script-beta/core/hover/class.lua new file mode 100644 index 00000000..6d28ee8a --- /dev/null +++ b/script-beta/core/hover/class.lua @@ -0,0 +1,27 @@ +local vm = require 'vm' + +local function getClass(source, deep) + if deep > 3 then + return nil + end + local class = vm.eachField(source, function (info) + if info.key == 's|type' or info.key == 's|__name' or info.key == 's|name' then + if info.value and info.value.type == 'string' then + return info.value[1] + end + end + end) + if class then + return class + end + return vm.eachMeta(source, function (meta) + local cl = getClass(meta, deep + 1) + if cl then + return cl + end + end) +end + +return function (source) + return getClass(source, 1) +end |